- improved Tx details view

- added functionality adding waveforms to list and navigating tx
This commit is contained in:
Eyck Jentzsch 2015-10-27 23:39:33 +01:00
parent 31af3b4c94
commit 070c947ae6
29 changed files with 795 additions and 246 deletions

View File

@ -188,6 +188,6 @@ public class Tx implements ITx {
@Override
public String toString() {
return "tx#"+getId()+"@"+getBeginTime()+"-@"+getEndTime();
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
}
}

View File

@ -88,33 +88,43 @@ import com.minres.scviewer.database.swt.internal.WaveformCanvas;
import swing2swt.layout.BorderLayout;
public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
private ListenerList selectionChangedListeners = new ListenerList();
private PropertyChangeSupport pcs;
public static final String CURSOR_PROPERTY = "cursor time";
private static final String SELECTION = "selection";
private ITx currentTxSelection;
private IWaveform<? extends IWaveformEvent> currentWaveformSelection;
private CursorPainter currentCursorSelection;
private ScrolledComposite nameListScrolled;
private ScrolledComposite valueListScrolled;
private Canvas nameList;
private Canvas valueList;
WaveformCanvas waveformList;
private Composite top;
protected ObservableList<IWaveform<? extends IWaveformEvent>> streams;
Vector<CursorPainter> cursorPainters;
private Composite trackPane;
private int trackVerticalHeight;
private TreeMap<Integer, IWaveform<? extends IWaveformEvent>> trackVerticalOffset;
private HashMap<IWaveform<? extends IWaveformEvent>, String> actualValues;
// private long maxTime=0;
private Font nameFont, nameFontB;
protected MouseListener nameValueMouseListener = new MouseAdapter() {
@ -389,10 +399,12 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
actualValues.clear();
waveformList.clearAllWavefromPainter();
boolean even = true;
boolean clearSelection = true;
TextLayout tl = new TextLayout(waveformList.getDisplay());
tl.setFont(nameFontB);
for (IWaveform<? extends IWaveformEvent> waveform : streams) {
int height = waveformList.getTrackHeight();
clearSelection &= (waveform != currentWaveformSelection);
if (waveform instanceof ITxStream<?>) {
ITxStream<? extends ITxEvent> stream = (ITxStream<? extends ITxEvent>) waveform;
height *= stream.getMaxConcurrency();
@ -421,7 +433,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
Point o = waveformList.getOrigin();
waveformList.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey()));
}
setSelection(new StructuredSelection());
if(clearSelection) setSelection(new StructuredSelection());
/* System.out.println("updateTracklist() state:");
for(Entry<Integer, IWaveform<? extends IWaveformEvent>> entry: trackVerticalOffset.entrySet()){
System.out.println(" "+entry.getKey()+": " +entry.getValue().getFullName());
@ -514,42 +526,44 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
@Override
public ISelection getSelection() {
if(currentCursorSelection != null){
return new StructuredSelection(currentCursorSelection);
}else if (currentTxSelection != null)
if (currentTxSelection != null)
return new StructuredSelection(currentTxSelection);
else if (currentWaveformSelection != null)
return new StructuredSelection(currentWaveformSelection);
else
return null;
return new StructuredSelection();
}
@Override
public void setSelection(ISelection selection) {
setSelection(selection, false);
}
@SuppressWarnings("unchecked")
@Override
public void setSelection(ISelection selection) {
public void setSelection(ISelection selection, boolean addIfNeeded) {
boolean selectionChanged = false;
if (selection instanceof IStructuredSelection) {
if(((IStructuredSelection) selection).size()==0){
selectionChanged = currentTxSelection!=null||currentWaveformSelection!=null;
currentTxSelection = null;
currentWaveformSelection = null;
currentCursorSelection=null;
} else {
for(Object sel:((IStructuredSelection) selection).toArray()){
if (sel instanceof ITx && currentTxSelection != sel && streams.contains(((ITx)sel).getStream())) {
currentTxSelection = (ITx) sel;
currentWaveformSelection = currentTxSelection.getStream();
currentCursorSelection=null;
if (sel instanceof ITx && currentTxSelection != sel){
ITx txSel = (ITx) sel;
if (streams.contains(((ITx)sel).getStream())) {
currentTxSelection = txSel;
currentWaveformSelection = txSel.getStream();
selectionChanged = true;
} else if(addIfNeeded){
streams.add(txSel.getStream());
currentTxSelection = txSel;
currentWaveformSelection = txSel.getStream();
selectionChanged = true;
}
} else if (sel instanceof IWaveform<?> && currentWaveformSelection != sel&& streams.contains(sel)) {
currentTxSelection = null;
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel;
currentCursorSelection=null;
selectionChanged = true;
} else if (sel instanceof CursorPainter && currentCursorSelection != sel){
currentTxSelection = null;
currentWaveformSelection = null;
currentCursorSelection=(CursorPainter) sel;
selectionChanged = true;
}
}
@ -559,7 +573,6 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
selectionChanged = true;
currentTxSelection = null;
currentWaveformSelection = null;
currentCursorSelection=null;
}
if (selectionChanged) {
waveformList.setSelected(currentTxSelection, currentWaveformSelection);
@ -823,6 +836,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y);
Object target = trackVerticalOffset.floorEntry(dropPoint.y).getValue();
if(source instanceof IWaveform<?> && target instanceof IWaveform<?>){
IWaveform<? extends IWaveformEvent> srcWave=(IWaveform<? extends IWaveformEvent>) source;
// int srcIdx=streams.indexOf(source);
// int tgtIdx=streams.indexOf(target);
// if(srcIdx<tgtIdx){
@ -830,10 +844,15 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
// } else {
// streams.rotate(tgtIdx, srcIdx+1, 1);
// }
int srcIdx=streams.indexOf(source);
int srcIdx=streams.indexOf(srcWave);
streams.remove(source);
int tgtIdx=streams.indexOf(target);
streams.add(srcIdx>tgtIdx?tgtIdx:tgtIdx+1, (IWaveform<? extends IWaveformEvent>) source);
if(srcIdx<=tgtIdx) tgtIdx++;
if(tgtIdx>=streams.size())
streams.add(srcWave);
else
streams.add(tgtIdx, srcWave);
currentWaveformSelection=srcWave;
updateTracklist();
} else if(source instanceof CursorPainter){
((CursorPainter)source).setTime(0);
@ -954,4 +973,9 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider {
return this.pcs.hasListeners(propertyName);
}
public String getScaledTime(Long time) {
StringBuilder sb = new StringBuilder();
return sb.append(time/waveformList.getScaleFactor()).append(waveformList.getUnitStr()).toString();
}
}

View File

@ -1,4 +1,4 @@
bin.includes = META-INF/,\
.,\
OSGI-INF/component.xml
OSGI-INF/
source.. = src/

View File

@ -59,4 +59,9 @@ class Tx implements ITx {
return id.compareTo(o.id)
}
@Override
public String toString() {
return "tx#"+getId()+"["+getBeginTime()/1000000+"ns - "+getEndTime()/1000000+"ns]";
}
}

View File

@ -24,6 +24,8 @@ public interface IWaveformDb extends IHierNode {
public boolean load(File inp) throws Exception;
public boolean isLoaded();
public void clear();
}

View File

@ -27,4 +27,7 @@ public class RelationType {
this.name = name;
}
public String toString(){
return name;
}
}

View File

@ -34,6 +34,8 @@ public class WaveformDb extends HierNode implements IWaveformDb {
private static List<IWaveformDbLoader> loaders=new LinkedList<IWaveformDbLoader>();
private boolean loaded;
private List<IHierNode> childNodes;
private Map<String, IWaveform<?>> waveforms;
@ -89,6 +91,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
buildHierarchyNodes() ;
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
pcs.firePropertyChange("CHILDS", null, childNodes);
loaded = true;
return true;
}
}
@ -108,6 +111,11 @@ public class WaveformDb extends HierNode implements IWaveformDb {
public void clear() {
waveforms.clear();
childNodes.clear();
loaded=false;
}
public boolean isLoaded() {
return loaded;
}
private void buildHierarchyNodes() throws InputFormatException{

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

View File

@ -1,16 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_95PfsHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ide.application" bindingContexts="_95PfuXNmEeWBq8z1Dv39LA">
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_95PfsHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ide.application" bindingContexts="_95PfuXNmEeWBq8z1Dv39LA">
<children xsi:type="basic:TrimmedWindow" xmi:id="_95PfsXNmEeWBq8z1Dv39LA" label="SC Viewer" width="980" height="700">
<children xsi:type="advanced:PerspectiveStack" xmi:id="_95QGxnNmEeWBq8z1Dv39LA">
<children xsi:type="advanced:Perspective" xmi:id="_95QGx3NmEeWBq8z1Dv39LA">
<children xsi:type="basic:PartSashContainer" xmi:id="_95QGyHNmEeWBq8z1Dv39LA" horizontal="true">
<children xsi:type="basic:PartSashContainer" xmi:id="_61hA8HTPEeWwZ-9vrAR2UQ" elementId="" containerData="20">
<children xsi:type="basic:Part" xmi:id="_95QGynNmEeWBq8z1Dv39LA" containerData="10" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.DesignBrowser" label="Design Browser"/>
<children xsi:type="basic:Part" xmi:id="_8KyKwHTPEeWwZ-9vrAR2UQ" containerData="9" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformListPart" label="Signal List"/>
<children xsi:type="basic:Part" xmi:id="_8KyKwHTPEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parts.WaveformList" containerData="9" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformListPart" label="Waveform List">
<handlers xmi:id="_Bx9s0Hr-EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.handler.addWaveformCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.AddWaveformHandler" command="_2PehEHr9EeWVM_sKoXvptg"/>
<menus xsi:type="menu:PopupMenu" xmi:id="_G6xAYHsDEeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.parts.WaveformList.popupmenu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_swdo8Hr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.handledmenuitem.append" label="Append after" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/append_wave.png" command="_2PehEHr9EeWVM_sKoXvptg">
<parameters xmi:id="_IA_lcHr_EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.parameter.21" name="com.minres.scviewer.e4.application.command.addwaveform.where" value="after"/>
<parameters xmi:id="_B6hTkHwJEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.parameter.25" name="com.minres.scviewer.e4.application.command.addwaveform.all" value="false"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_twC2oHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.handledmenuitem.insertbefore" label="Insert before" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/insert_wave.png" command="_2PehEHr9EeWVM_sKoXvptg">
<parameters xmi:id="_KQPEMHr_EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.parameter.22" name="com.minres.scviewer.e4.application.command.addwaveform.where" value="before"/>
<parameters xmi:id="_Em0hwHwJEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.parameter.26" name="com.minres.scviewer.e4.application.command.addwaveform.all" value="false"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_uMoE8Hr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.handledmenuitem.appendall" label="Append all" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/append_all_waves.png" command="_2PehEHr9EeWVM_sKoXvptg">
<parameters xmi:id="_LpOQYHr_EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.parameter.23" name="com.minres.scviewer.e4.application.command.addwaveform.where" value="after"/>
<parameters xmi:id="_G-T9kHwJEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.parameter.27" name="com.minres.scviewer.e4.application.command.addwaveform.all" value="true"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_ukpjYHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.handledmenuitem.insertall" label="Insert All" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/insert_all_waves.png" command="_2PehEHr9EeWVM_sKoXvptg">
<parameters xmi:id="_M9U8kHr_EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.parameter.24" name="com.minres.scviewer.e4.application.command.addwaveform.where" value="before"/>
<parameters xmi:id="_ckAToHwJEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.parameter.28" name="com.minres.scviewer.e4.application.command.addwaveform.all" value="true"/>
</children>
</menus>
</children>
</children>
<children xsi:type="basic:PartSashContainer" xmi:id="_uT9BIHgtEeWwZ-9vrAR2UQ" elementId="" containerData="80">
<children xsi:type="basic:PartStack" xmi:id="_95QGyXNmEeWBq8z1Dv39LA" elementId="org.eclipse.editorss" containerData="80"/>
<children xsi:type="basic:Part" xmi:id="_vtfm8HgtEeWwZ-9vrAR2UQ" elementId="" containerData="20" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.TransactionDetails"/>
<children xsi:type="basic:PartStack" xmi:id="_95QGyXNmEeWBq8z1Dv39LA" elementId="org.eclipse.editorss" containerData="75"/>
<children xsi:type="basic:Part" xmi:id="_vtfm8HgtEeWwZ-9vrAR2UQ" elementId="" containerData="25" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.TransactionDetails"/>
</children>
</children>
</children>
@ -101,7 +121,9 @@
<children xsi:type="menu:ToolControl" xmi:id="_YsBi8HfLEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.StatusLine" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.WaveStatusBarControl">
<tags>stretch</tags>
</children>
<children xsi:type="menu:ToolControl" xmi:id="_VZzJMHdHEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.HeapStatus" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.StatusBarControl"/>
<children xsi:type="menu:ToolControl" xmi:id="_VZzJMHdHEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.HeapStatus" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.StatusBarControl">
<tags>Draggable</tags>
</children>
<children xsi:type="menu:ToolControl" xmi:id="_y0ZS0HfzEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.ProgressBar" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.StatusBarControl">
<tags>Draggable</tags>
</children>
@ -131,31 +153,43 @@
<handlers xmi:id="_Du1NAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.zoomCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ZoomHandler" command="_693GoHcqEeWwZ-9vrAR2UQ"/>
<menus xsi:type="menu:PopupMenu" xmi:id="_TwzrsHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.namecontext" label="Name Menu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vco7YHWSEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_elFdcHr_EeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
<parameters xmi:id="_qNG5kHZWEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.0" name="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" value="up"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_UlTbMHXIEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.movedown" label="Move down" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/down_blue.png" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_eBN0AHsCEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
<parameters xmi:id="_soO4MHZWEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.1" name="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" value="down"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vj4jUHXIEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.remove" label="Remove" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vj4jUHXIEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.remove" label="Remove" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_f6MH0HsCEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
</children>
</menus>
<menus xsi:type="menu:PopupMenu" xmi:id="_CxJvAHXGEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.wavecontext" label="Wave Menu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_7HrlwHXREeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_orHK4HsCEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
<parameters xmi:id="_snsmsHaYEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.2" name="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" value="up"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_8MkxQHXREeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.movedown" label="Move down" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/down_blue.png" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_sSb24HsCEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
<parameters xmi:id="_uZBaYHaYEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.3" name="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir" value="down"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_7Hz3sHXIEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.remove" label="Remove" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_uusd8HsCEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_h4B6YHcZEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.nextevent" label="Next event" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/play_blue.png" command="_79rx4HabEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_mDkrcHsDEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
<parameters xmi:id="_rKkcwHcZEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.6" name="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" value="next"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_kU1UAHcZEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.previousevent" label="Previous event" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_blue.png" command="_79rx4HabEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_mdnjIHsDEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
<parameters xmi:id="_tJOh0HcZEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.7" name="com.minres.scviewer.e4.application.command.navigateEventCommand.parameter.dir" value="prev"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_7Hz3sHXIEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.remove" label="Remove" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_33qXsHabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.nextchange" label="Next Tx" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/play_green.png" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_m2RTsHsDEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneTxSeleted"/>
<parameters xmi:id="_33qXsXabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.4" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="next"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_4ZeEQHabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.previouschange" label="Previous Tx" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/reverse_green.png" command="_Gn3lEHXKEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_nReB8HsDEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneTxSeleted"/>
<parameters xmi:id="_4ZeEQXabEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.5" name="com.minres.scviewer.e4.application.command.navigateTransCommand.parameter.dir" value="prev"/>
</children>
</menus>
@ -178,6 +212,10 @@
<commands xmi:id="_693GoHcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.zoomcommand" commandName="zoomCommand">
<parameters xmi:id="_8tbm0HcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" name="level" optional="false"/>
</commands>
<commands xmi:id="_2PehEHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.command.addwaveform" commandName="addWaveformCommand">
<parameters xmi:id="_6KsZcHr9EeWVM_sKoXvptg" elementId="com.minres.scviewer.e4.application.command.addwaveform.where" name="where" optional="false"/>
<parameters xmi:id="_7T1TcHwIEeWv0Y5uF2QN5w" elementId="com.minres.scviewer.e4.application.command.addwaveform.all" name="all" typeId="" optional="false"/>
</commands>
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>

View File

@ -1,9 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Application
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: MINRES Technologies GmbH
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.11.1",
org.eclipse.swt;bundle-version="3.104.1",
@ -24,7 +24,9 @@ Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.jobs,
org.eclipse.osgi,
com.google.guava,
org.eclipse.equinox.preferences
org.eclipse.equinox.preferences,
org.eclipse.core.expressions,
org.eclipse.e4.core.commands;bundle-version="0.11.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.minres.scviewer.database,
javax.inject;version="1.0.0"

View File

@ -0,0 +1,5 @@
#Properties file for com.minres.scviewer.e4.application
Bundle-Vendor = MINRES Technologies GmbH
Bundle-Name = Application
product.description = SystemC Transaction and Waveform Viewer
product.name = SCViewer

View File

@ -5,5 +5,6 @@ bin.includes = META-INF/,\
plugin.xml,\
Application.e4xmi,\
icons/,\
css/default.css
css/default.css,\
OSGI-INF/l10n/bundle.properties
source.. = src/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -6,8 +6,8 @@
point="org.eclipse.core.runtime.products">
<product
application="org.eclipse.e4.ui.workbench.swt.E4Application"
description="SystemC Transaction and Waveform Viewer"
name="SCViewer">
description="%product.description"
name="%product.name">
<property
name="lifeCycleURI"
value="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.E4LifeCycle">
@ -22,5 +22,47 @@
</property>
</product>
</extension>
<extension
point="org.eclipse.core.expressions.definitions">
<definition
id="com.minres.scviewer.e4.application.oneWaveSeleted">
<with
variable="selection">
<and>
<count
value="1">
</count>
<iterate
operator="or">
<instanceof value="com.minres.scviewer.database.IWaveform"/>
</iterate>
</and>
</with>
</definition>
<definition
id="com.minres.scviewer.e4.application.oneTxSeleted">
<with
variable="selection">
<and>
<count
value="1">
</count>
<iterate
operator="or">
<instanceof value="com.minres.scviewer.database.ITx"/>
</iterate>
</and>
</with>
</definition>
<definition
id="com.minres.scviewer.e4.application.waveformViewerActive">
<with
variable="activeEditorId">
<equals
value="com.minres.scviewer.e4.application.partdescriptor.waveformviewer">
</equals>
</with>
</definition>
</extension>
</plugin>

View File

@ -10,11 +10,28 @@
*******************************************************************************/
package com.minres.scviewer.e4.application;
import java.io.File;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
import org.eclipse.e4.ui.workbench.lifecycle.PreSave;
import org.eclipse.e4.ui.workbench.lifecycle.ProcessAdditions;
import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
import org.eclipse.equinox.app.IApplicationContext;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
/**
* This is a stub implementation containing e4 LifeCycle annotated methods.<br />
@ -25,10 +42,30 @@ import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals;
@SuppressWarnings("restriction")
public class E4LifeCycle {
@PostContextCreate
void postContextCreate(IEclipseContext workbenchContext) {
@PostConstruct
private static void postConstruct(final IEventBroker eventBroker) {
}
@PostContextCreate
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) {
final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
// react on the first view being created, at that time the UI is available
eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
@Override
public void handleEvent(Event event) {
MPart part = (MPart) event.getProperty("ChangedElement");
if(part!=null){
IEclipseContext ctx = part.getContext();
OpenViewHandler openViewHandler= new OpenViewHandler();
ContextInjectionFactory.inject(openViewHandler, ctx);
eventBroker.unsubscribe(this);
for(String name:args){
if(new File(name).exists()) openViewHandler.openViewForFile(name);
}
}
}
});
}
@PreSave
void preSave(IEclipseContext workbenchContext) {
}
@ -40,4 +77,31 @@ public class E4LifeCycle {
@ProcessRemovals
void processRemovals(IEclipseContext workbenchContext) {
}
String join(String[] tokens){
StringBuilder sb = new StringBuilder();
boolean first=true;
for(String token:tokens){
if(!first) sb.append(",");
sb.append(token);
first=false;
}
return sb.toString();
}
private class OpenViewHandler {
@Inject MApplication app;
@Inject EModelService modelService;
@Inject EPartService partService;
public void openViewForFile(String name){
MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer");
part.setLabel(name);
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app);
partStack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
IEclipseContext ctx=part.getContext();
ctx.modify("input", new File(name));
ctx.declareModifiable("input");
}
}
}

View File

@ -0,0 +1,58 @@
package com.minres.scviewer.e4.application.handlers;
import java.util.List;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.e4.application.parts.WaveformListPart;
public class AddWaveformHandler {
public final static String PARAM_WHERE_ID="com.minres.scviewer.e4.application.command.addwaveform.where";
public final static String PARAM_ALL_ID="com.minres.scviewer.e4.application.command.addwaveform.all";
@CanExecute
public boolean canExecute(@Named(PARAM_WHERE_ID) String where, @Named(PARAM_ALL_ID) String all,
EPartService partService,
@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection) {
WaveformListPart listPart = getListPart( partService);
if(listPart==null || listPart.getActiveWaveformViewerPart()==null) return false;
Boolean before = "before".equalsIgnoreCase(where);
if("true".equalsIgnoreCase(all))
return listPart.getFilteredChildren().length>0 &&
(!before || ((IStructuredSelection)listPart.getActiveWaveformViewerPart().getSelection()).size()>0);
else
return selection.size()>0 &&
(!before || ((IStructuredSelection)listPart.getActiveWaveformViewerPart().getSelection()).size()>0);
}
@Execute
public void execute(@Named(PARAM_WHERE_ID) String where, @Named(PARAM_ALL_ID) String all,
EPartService partService,
@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection) {
WaveformListPart listPart = getListPart( partService);
if(listPart!=null && selection.size()>0){
List<?> sel=selection.toList();
listPart.getActiveWaveformViewerPart().addStreamsToList(sel.toArray(new IWaveform<?>[]{}),
"before".equalsIgnoreCase(where));
}
}
protected WaveformListPart getListPart(EPartService partService){
MPart part = partService.getActivePart();
if(part.getObject() instanceof WaveformListPart)
return (WaveformListPart) part.getObject();
else
return null;
}
}

View File

@ -15,6 +15,7 @@ import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
@ -24,16 +25,15 @@ public class DeleteWaveformHandler {
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
return o instanceof IWaveform<?>;
return o instanceof IStructuredSelection && ((IStructuredSelection)o).getFirstElement() instanceof IWaveform<?>;
}
@Execute
public void execute(ESelectionService selectionService, MPart activePart) {
Object o = activePart.getObject();
Object sel = selectionService.getSelection();
if(o instanceof WaveformViewerPart && sel instanceof IWaveform<?>){
((WaveformViewerPart)o).removeStreamFromList((IWaveform<?>) sel);
if(o instanceof WaveformViewerPart && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform<?>){
((WaveformViewerPart)o).removeStreamFromList((IWaveform<?>) ((IStructuredSelection)sel).getFirstElement());
}
}
}

View File

@ -18,6 +18,7 @@ import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
@ -29,9 +30,13 @@ public class MoveWaveformHandler {
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
Object sel = selectionService.getSelection();
if( sel instanceof IStructuredSelection) {
Object o= ((IStructuredSelection)sel).getFirstElement();
return o instanceof IWaveform<?> || o instanceof ITx;
}
return false;
}
@Execute
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {

View File

@ -18,6 +18,7 @@ import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
@ -30,9 +31,13 @@ public class NavigateEvent {
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
Object sel = selectionService.getSelection();
if( sel instanceof IStructuredSelection) {
Object o= ((IStructuredSelection)sel).getFirstElement();
return o instanceof IWaveform<?> || o instanceof ITx;
}
return false;
}
@Execute
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {

View File

@ -18,6 +18,7 @@ import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.IStructuredSelection;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.swt.GotoDirection;
@ -29,9 +30,13 @@ public class NavigateTrans {
@CanExecute
public Boolean canExecute(ESelectionService selectionService){
Object o = selectionService.getSelection();
Object sel = selectionService.getSelection();
if( sel instanceof IStructuredSelection) {
Object o= ((IStructuredSelection)sel).getFirstElement();
return o instanceof ITx;
}
return false;
}
@Execute
public void execute(@Named(PARAMTER_ID) String param, EPartService partService) {

View File

@ -10,8 +10,6 @@
*******************************************************************************/
package com.minres.scviewer.e4.application.internal;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
@ -22,6 +20,7 @@ import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.GridData;
@ -87,13 +86,19 @@ public class WaveStatusBarControl extends StatusBarControl {
}
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION)@Optional Object obj){
// if(status!=null ) status.setText(obj==null?"":obj.toString());
if(manager!=null ){
if(obj instanceof List<?>){
manager.setMessage(""+((List<?>)obj).size()+" Elements");
} else
manager.setMessage(obj==null?"":obj.getClass().getSimpleName()+" selected");
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION)@Optional IStructuredSelection selection){
if(manager!=null && selection!=null){
switch(selection.size()){
case 0:
manager.setMessage("");
break;
case 1:
manager.setMessage(selection.getFirstElement().getClass().getSimpleName()+" selected");
break;
default:
manager.setMessage(""+selection.size()+" Elements");
break;
}
}
}

View File

@ -23,9 +23,7 @@ import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
@ -45,6 +43,7 @@ public class DesignBrowser implements ISelectionChangedListener {
private TreeViewer contentOutlineViewer;
private PropertyChangeListener l = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@ -59,6 +58,7 @@ public class DesignBrowser implements ISelectionChangedListener {
}
};
@PostConstruct
public void createComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
@ -73,38 +73,22 @@ public class DesignBrowser implements ISelectionChangedListener {
@Focus
public void setFocus() {
contentOutlineViewer.getTree().setFocus();
setSelection(contentOutlineViewer.getSelection());
selectionService.setSelection(contentOutlineViewer.getSelection());
}
@Override
public void selectionChanged(SelectionChangedEvent event) {
setSelection(event.getSelection());
}
protected void setSelection(ISelection iSelection) {
IStructuredSelection selection = (IStructuredSelection)iSelection;
switch(selection.size()){
case 0:
eventBroker.post(WaveformViewerPart.ACTIVE_NODE, null);
break;
case 1:
eventBroker.post(WaveformViewerPart.ACTIVE_NODE, selection.getFirstElement());
selectionService.setSelection(selection.getFirstElement());
break;
default:
eventBroker.post(WaveformViewerPart.ACTIVE_NODE, selection.getFirstElement());
selectionService.setSelection(selection.toList());
break;
}
selectionService.setSelection(event.getSelection());
}
@SuppressWarnings("unchecked")
@Inject @Optional
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_DATABASE) IWaveformDb database) {
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart waveformViewerPart) {
IWaveformDb database = waveformViewerPart.getDatabase();
Object input = contentOutlineViewer.getInput();
if(input!=null && input instanceof List<?>)
((List<IWaveformDb>)input).get(0).removePropertyChangeListener(l);
contentOutlineViewer.setInput(Arrays.asList(new IWaveformDb[]{database}));
contentOutlineViewer.setInput(database.isLoaded()?Arrays.asList(new IWaveformDb[]{database}):null);
// Set up the tree viewer
database.addPropertyChangeListener(l);
}

View File

@ -10,6 +10,8 @@
*******************************************************************************/
package com.minres.scviewer.e4.application.parts;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
@ -17,9 +19,21 @@ import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
@ -35,13 +49,12 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.e4.application.provider.TxPropertiesContentProvider;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
public class TransactionDetails {
@ -51,15 +64,24 @@ public class TransactionDetails {
public static final int COLUMN_SECOND = 1;
public static final int COLUMN_THIRD = 2;
@Inject IEventBroker eventBroker;
@Inject ESelectionService selectionService;
private Text nameFilter;
private TableViewer txTableViewer;
private TableColumn col1, col2;
private TreeViewer treeViewer;
private TreeViewerColumn col1, col2, col3;
TxAttributeFilter attributeFilter;
TxAttributeViewerSorter viewSorter;
private WaveformViewerPart waveformViewerPart;
@PostConstruct
public void createComposite(final Composite parent) {
@ -71,57 +93,89 @@ public class TransactionDetails {
@Override
public void modifyText(ModifyEvent e) {
attributeFilter.setSearchText(((Text) e.widget).getText());
txTableViewer.refresh();
treeViewer.refresh();
}
});
nameFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
attributeFilter = new TxAttributeFilter();
viewSorter = new TxAttributeViewerSorter();
txTableViewer = new TableViewer(parent);
txTableViewer.setContentProvider(new TxPropertiesContentProvider());
txTableViewer.setLabelProvider(new TxPropertiesLabelProvider());
txTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
txTableViewer.addFilter(attributeFilter);
treeViewer = new TreeViewer(parent);
treeViewer.setContentProvider(new TransactionTreeContentProvider());
treeViewer.setLabelProvider(new TxPropertiesLabelProvider());
treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
treeViewer.addFilter(attributeFilter);
treeViewer.setSorter(viewSorter);
treeViewer.setAutoExpandLevel(2);
// Set up the table
Table table = txTableViewer.getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH));
// Add the first name column
col1 = new TableColumn(table, SWT.LEFT);
col1.setText("Name");
col1.setResizable(true);
col1.addSelectionListener(new SelectionAdapter() {
Tree tree = treeViewer.getTree();
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
// Add the name column
col1 = new TreeViewerColumn(treeViewer, SWT.NONE);
col1.getColumn().setText("Name");
col1.getColumn().setResizable(true);
col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.NAME)));
col1.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((TxAttributeViewerSorter) txTableViewer.getSorter()).doSort(COLUMN_FIRST);
txTableViewer.refresh();
((TxAttributeViewerSorter) treeViewer.getSorter()).doSort(COLUMN_FIRST);
treeViewer.refresh();
}
});
// Add the last name column
col2 = new TableColumn(table, SWT.LEFT);
col2.setText("Value");
col2.setResizable(true);
col2.addSelectionListener(new SelectionAdapter() {
// Add the type column
col2 = new TreeViewerColumn(treeViewer, SWT.NONE);
col2.getColumn().setText("Type");
col2.getColumn().setResizable(true);
col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.TYPE)));
col2.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((TxAttributeViewerSorter) txTableViewer.getSorter()).doSort(COLUMN_SECOND);
txTableViewer.refresh();
((TxAttributeViewerSorter) treeViewer.getSorter()).doSort(COLUMN_SECOND);
treeViewer.refresh();
}
});
// Add the value column
col3 = new TreeViewerColumn(treeViewer, SWT.NONE);
col3.getColumn().setText("Value");
col3.getColumn().setResizable(true);
col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.VALUE)));
col3.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((TxAttributeViewerSorter) treeViewer.getSorter()).doSort(COLUMN_SECOND);
treeViewer.refresh();
}
});
// Pack the columns
for (int i = 0, n = table.getColumnCount(); i < n; i++) {
table.getColumn(i).pack();
}
// for (int i = 0, n = table.getColumnCount(); i < n; i++) {
// table.getColumn(i).pack();
// }
// Turn on the header and the lines
table.setHeaderVisible(true);
table.setLinesVisible(true);
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
treeViewer.addDoubleClickListener(new IDoubleClickListener(){
@Override
public void doubleClick(DoubleClickEvent event) {
ISelection selection = treeViewer.getSelection();
if(selection instanceof IStructuredSelection){
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object selected = structuredSelection.getFirstElement();
if(selected instanceof Object[]){
Object[] selectedArray = (Object[]) selected;
if(selectedArray.length==3 && selectedArray[2] instanceof ITx){
waveformViewerPart.setSelection(new StructuredSelection(selectedArray[2]));
treeViewer.setInput(selectedArray[2]);
}
}
}
}
});
parent.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Table table = txTableViewer.getTable();
Tree table = treeViewer.getTree();
Rectangle area = parent.getClientArea();
Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = area.width - 2*table.getBorderWidth();
@ -136,16 +190,18 @@ public class TransactionDetails {
// table is getting smaller so make the columns
// smaller first and then resize the table to
// match the client area width
col1.setWidth(width/3);
col2.setWidth(width - col1.getWidth());
col1.getColumn().setWidth(width/3);
col2.getColumn().setWidth(width/4);
col3.getColumn().setWidth(width - col1.getColumn().getWidth());
table.setSize(area.width, area.height);
} else {
// table is getting bigger so make the table
// bigger first and then make the columns wider
// to match the client area width
table.setSize(area.width, area.height);
col1.setWidth(width/3);
col2.setWidth(width - col1.getWidth());
col1.getColumn().setWidth(width/3);
col2.getColumn().setWidth(width/4);
col3.getColumn().setWidth(width - col1.getColumn().getWidth()- col2.getColumn().getWidth());
}
}
});
@ -153,18 +209,38 @@ public class TransactionDetails {
@Focus
public void setFocus() {
txTableViewer.getTable().setFocus();
treeViewer.getTree().setFocus();
}
@Inject @Optional
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart part) {
this.waveformViewerPart=part;
}
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional Object object){
if(txTableViewer!=null && !txTableViewer.getTable().isDisposed())
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection){
if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
if( selection instanceof IStructuredSelection) {
Object object= ((IStructuredSelection)selection).getFirstElement();
if(object instanceof ITx){
txTableViewer.setInput(object);
treeViewer.setInput(object);
} else {
txTableViewer.setInput(null);
treeViewer.setInput(null);
}
}
}
}
String timeToString(Long time){
return waveformViewerPart.getScaledTime(time);
}
String txToString(ITx tx){
StringBuilder sb = new StringBuilder();
sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())).
append(" - ").append(timeToString(tx.getEndTime())).append("]");
return sb.toString();
}
class TxAttributeViewerSorter extends ViewerSorter {
private static final int ASCENDING = 0;
@ -199,28 +275,29 @@ public class TransactionDetails {
@SuppressWarnings("unchecked")
public int compare(Viewer viewer, Object e1, Object e2) {
int rc = 0;
if(e1 instanceof ITxAttribute && e2 instanceof ITxAttribute){
ITxAttribute p1 = (ITxAttribute) e1;
ITxAttribute p2 = (ITxAttribute) e2;
// Determine which column and do the appropriate sort
switch (column) {
case COLUMN_FIRST:
rc = getComparator().compare(p1.getName(), p2.getName());
break;
case COLUMN_SECOND:
rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name());
break;
case COLUMN_THIRD:
rc = getComparator().compare(p1.getValue(), p2.getValue());
break;
}
// If descending order, flip the direction
if (direction == DESCENDING)
rc = -rc;
if (direction == DESCENDING) rc = -rc;
}
return rc;
}
}
public class TxAttributeFilter extends ViewerFilter {
class TxAttributeFilter extends ViewerFilter {
private String searchString;
@ -233,11 +310,147 @@ public class TransactionDetails {
if (searchString == null || searchString.length() == 0) {
return true;
}
if(element instanceof ITxAttribute){
ITxAttribute p = (ITxAttribute) element;
if (p.getName().matches(searchString)) {
return true;
}
} else if(element instanceof TreeNode)
return true;
return false;
}
}
enum Type {TIMES, PROPS, IN_REL, OUT_REL}
class TreeNode{
public Type type;
public ITx element;
public TreeNode(ITx element, Type type){
this.element=element;
this.type=type;
}
public String toString(){
switch(type){
case TIMES: return "Times";
case PROPS: return "Attributes";
case IN_REL: return "Incoming relations";
case OUT_REL: return "Outgoing relations";
}
return "";
}
}
class TransactionTreeContentProvider implements ITreeContentProvider {
@Override
public void dispose() { }
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public Object[] getElements(Object element) {
return new Object[]{
new TreeNode((ITx)element, Type.TIMES),
new TreeNode((ITx)element, Type.PROPS),
new TreeNode((ITx)element, Type.IN_REL),
new TreeNode((ITx)element, Type.OUT_REL)
};
}
@Override
public Object[] getChildren(Object element) {
if(element instanceof TreeNode){
TreeNode propertyHolder=(TreeNode) element;
if(propertyHolder.type == Type.TIMES)
return new Object[][]{
{"Start time", "", timeToString(propertyHolder.element.getBeginTime())},
{"End time", "", timeToString(propertyHolder.element.getEndTime())}};
else if(propertyHolder.type == Type.PROPS)
return propertyHolder.element.getAttributes().toArray();
else if(propertyHolder.type == Type.IN_REL){
Vector<Object[] > res = new Vector<>();
for(ITxRelation rel:propertyHolder.element.getIncomingRelations()){
res.add(new Object[]{
rel.getRelationType(),
rel.getSource().getGenerator().getName(),
txToString(rel.getSource())});
}
return res.toArray();
} else if(propertyHolder.type == Type.OUT_REL){
Vector<Object[] > res = new Vector<>();
for(ITxRelation rel:propertyHolder.element.getOutgoingRelations()){
res.add(new Object[]{
rel.getRelationType(),
rel.getTarget().getGenerator().getName(),
txToString(rel.getTarget())});
}
return res.toArray();
}
}
return null;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public boolean hasChildren(Object element) {
return getChildren(element)!=null;
}
}
class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
final int field;
public static final int NAME=0;
public static final int TYPE=1;
public static final int VALUE=2;
public AttributeLabelProvider(int field) {
this.field=field;
}
@Override
public StyledString getStyledText(Object element) {
switch(field){
case NAME:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
return new StyledString(attribute.getName());
}else if (element instanceof ITxRelation) {
return new StyledString("Relation");
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
} else
return new StyledString(element.toString());
case TYPE:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
return new StyledString(attribute.getDataType().toString());
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
}else
return new StyledString("");
default:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
return new StyledString(attribute.getValue().toString());
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
}else
return new StyledString("");
}
}
}
}

View File

@ -10,25 +10,33 @@
*******************************************************************************/
package com.minres.scviewer.e4.application.parts;
import java.util.Arrays;
import java.lang.annotation.Annotation;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
@ -45,23 +53,38 @@ import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.wb.swt.ResourceManager;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.e4.application.handlers.AddWaveformHandler;
import com.minres.scviewer.e4.application.provider.TxDbContentProvider;
import com.minres.scviewer.e4.application.provider.TxDbLabelProvider;
public class WaveformListPart implements ISelectionChangedListener {
private static final String POPUP_ID="com.minres.scviewer.e4.application.parts.WaveformList.popupmenu";
@Inject IEventBroker eventBroker;
@Inject ESelectionService selectionService;
@Inject EMenuService menuService;
@Inject IEclipseContext eclipseCtx;
private Text nameFilter;
private TableViewer txTableViewer;
ToolItem appendItem, insertItem, insertAllItem, appendAllItem;
WaveformAttributeFilter attributeFilter;
int thisSelectionCount=0, otherSelectionCount=0;
private WaveformViewerPart waveformViewerPart;
@PostConstruct
public void createComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
@ -86,40 +109,64 @@ public class WaveformListPart implements ISelectionChangedListener {
txTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
txTableViewer.addSelectionChangedListener(this);
txTableViewer.addFilter(attributeFilter);
txTableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "after", false);
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
}
});
menuService.registerContextMenu(txTableViewer.getControl(), POPUP_ID);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.RIGHT);
toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
toolBar.setBounds(0, 0, 87, 20);
appendItem = new ToolItem(toolBar, SWT.NONE);
appendItem.setToolTipText("Append selected");
appendItem.setToolTipText("Append after");
appendItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/append_wave.png"));
appendItem.setEnabled(false);
appendItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
/*
eventBroker.post(WaveformViewerPart.ADD_WAVEFORM,
((IStructuredSelection)txTableViewer.getSelection()).toList());
ECommandService commandService = eclipseCtx.get(ECommandService.class);
EHandlerService handlerService = eclipseCtx.get(EHandlerService.class);
HashMap<String,Object> param=new HashMap<>();
param.clear();
//param.put("where", "after");
ParameterizedCommand myCommand = commandService.createCommand(COMMAND_ID, param);
if(myCommand!=null)handlerService.executeHandler(myCommand);
*/
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "after", false);
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
}
});
insertItem = new ToolItem(toolBar, SWT.NONE);
insertItem.setToolTipText("Insert selected");
insertItem.setToolTipText("Insert before");
insertItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/insert_wave.png"));
insertItem.setEnabled(false);
insertItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
eventBroker.post(WaveformViewerPart.ADD_WAVEFORM,
((IStructuredSelection)txTableViewer.getSelection()).toList());
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "before", false);
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
appendAllItem = new ToolItem(toolBar, SWT.NONE);
appendAllItem.setToolTipText("Append all");
appendAllItem.setToolTipText("Append all after");
appendAllItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/append_all_waves.png"));
appendAllItem.setEnabled(false);
@ -128,22 +175,34 @@ public class WaveformListPart implements ISelectionChangedListener {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] all = getFilteredChildren(txTableViewer);
if(all.length>0)
eventBroker.post(WaveformViewerPart.ADD_WAVEFORM, Arrays.asList(all));
if(all.length>0){
Object oldSel=selectionService.getSelection();
selectionService.setSelection(new StructuredSelection(all));
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "after", false);
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
selectionService.setSelection(oldSel);
}
}
});
insertAllItem = new ToolItem(toolBar, SWT.NONE);
insertAllItem.setToolTipText("Insert all");
insertAllItem.setToolTipText("Insert all before");
insertAllItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/insert_all_waves.png"));
insertAllItem.setEnabled(false);
insertAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] all = getFilteredChildren(txTableViewer);
if(all.length>0)
eventBroker.post(WaveformViewerPart.ADD_WAVEFORM, Arrays.asList(all));
if(all.length>0){
Object oldSel=selectionService.getSelection();
selectionService.setSelection(new StructuredSelection(all));
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "before", false);
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
selectionService.setSelection(oldSel);
}
}
});
}
@ -155,8 +214,8 @@ public class WaveformListPart implements ISelectionChangedListener {
}
@Inject @Optional
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_NODE) Object o) {
txTableViewer.setInput(o);
public void getStatusEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_WAVEFORMVIEW) WaveformViewerPart part) {
this.waveformViewerPart=part;
updateButtons();
}
@ -167,37 +226,40 @@ public class WaveformListPart implements ISelectionChangedListener {
protected void setSelection(ISelection iSelection) {
IStructuredSelection selection = (IStructuredSelection)iSelection;
switch(selection.size()){
case 0:
if(selection.size()==0){
appendItem.setEnabled(false);
break;
case 1:
selectionService.setSelection(selection.getFirstElement());
break;
default:
selectionService.setSelection(selection.toList());
break;
}
selectionService.setSelection(selection);
thisSelectionCount=selection.toList().size();
updateButtons();
}
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional Object object, EPartService partService){
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
MPart part = partService.getActivePart();
if(part!=null && part.getObject() != this)
if(part!=null && part.getObject() != this && selection!=null){
if( selection instanceof IStructuredSelection) {
Object object= ((IStructuredSelection)selection).getFirstElement();
if(object instanceof IHierNode&& !(object instanceof IWaveform<?>))
txTableViewer.setInput(object);
otherSelectionCount = (object instanceof IWaveform<?> || object instanceof ITx)?1:0;
}
}
updateButtons();
}
private void updateButtons() {
if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed() &&
!appendAllItem.isDisposed() && !insertAllItem.isDisposed()){
Object[] all = getFilteredChildren(txTableViewer);
appendItem.setEnabled(thisSelectionCount>0);
appendAllItem.setEnabled(all.length>0);
insertItem.setEnabled(thisSelectionCount>0 && otherSelectionCount>0);
insertAllItem.setEnabled(all.length>0 && otherSelectionCount>0);
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "after", false);
appendItem.setEnabled(result instanceof Boolean && (Boolean)result);
result = runCommand(myHandler, CanExecute.class, "after", true);
appendAllItem.setEnabled(result instanceof Boolean && (Boolean)result);
result = runCommand(myHandler, CanExecute.class, "before", false);
insertItem.setEnabled(result instanceof Boolean && (Boolean)result);
result = runCommand(myHandler, CanExecute.class, "before", true);
insertAllItem.setEnabled(result instanceof Boolean && (Boolean)result);
}
}
@ -222,6 +284,10 @@ public class WaveformListPart implements ISelectionChangedListener {
}
}
public Object[] getFilteredChildren(){
return getFilteredChildren(txTableViewer);
}
protected Object[] getFilteredChildren(TableViewer viewer){
Object parent = viewer.getInput();
if(parent==null) return new Object[0];
@ -245,4 +311,17 @@ public class WaveformListPart implements ISelectionChangedListener {
}
return result;
}
public WaveformViewerPart getActiveWaveformViewerPart() {
return waveformViewerPart;
}
protected Object runCommand(AddWaveformHandler myHandler, Class<? extends Annotation> annotation, String where, Boolean all) {
ContextInjectionFactory.inject(myHandler, eclipseCtx);
eclipseCtx.set(AddWaveformHandler.PARAM_WHERE_ID, where);
eclipseCtx.set(AddWaveformHandler.PARAM_ALL_ID, all.toString());
Object result = ContextInjectionFactory.invoke(myHandler, annotation, eclipseCtx);
return result;
}
}

View File

@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -42,12 +41,12 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.widgets.Composite;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
@ -59,9 +58,7 @@ import com.minres.scviewer.e4.application.internal.StatusBarControl;
public class WaveformViewerPart {
public static final String ACTIVE_DATABASE="Active_Database";
public static final String ACTIVE_NODE="ActiveNode";
public static final String ACTIVE_NODE_PATH="ActiveNodePath";
public static final String ACTIVE_WAVEFORMVIEW="Active_Waveform_View";
public static final String ADD_WAVEFORM="AddWaveform";
protected static final String DATABASE_FILE = "DATABASE_FILE";
@ -88,8 +85,6 @@ public class WaveformViewerPart {
private IWaveformDb database;
private IHierNode activeNode;
private Composite myParent;
ArrayList<File> filesToLoad;
@ -128,12 +123,7 @@ public class WaveformViewerPart {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if(event.getSelection() instanceof IStructuredSelection)
for(Object o:((IStructuredSelection)event.getSelection()).toList()){
if(o instanceof ITx || o instanceof IWaveform<?>){
selectionService.setSelection(o);
return;
}
}
selectionService.setSelection(event.getSelection());
}
});
filesToLoad=new ArrayList<File>();
@ -159,7 +149,7 @@ public class WaveformViewerPart {
subMonitor.setTaskName("Loading database");
try {
for(File file: filesToLoad){
TimeUnit.SECONDS.sleep(2);
//TimeUnit.SECONDS.sleep(2);
database.load(file);
database.addPropertyChangeListener(txDisplay);
subMonitor.worked(1);
@ -237,8 +227,6 @@ public class WaveformViewerPart {
persistedState.put(DATABASE_FILE+index, file.getAbsolutePath());
index++;
}
if(activeNode!=null)
persistedState.put(ACTIVE_NODE_PATH, activeNode.getFullName());
persistedState.put(SHOWN_WAVEFORM+"S", Integer.toString(txDisplay.getStreamList().size()));
index=0;
for(IWaveform<? extends IWaveformEvent> waveform:txDisplay.getStreamList()){
@ -249,8 +237,6 @@ public class WaveformViewerPart {
protected void restoreState() {
updateAll();
String hierName = persistedState.get(ACTIVE_NODE_PATH);
if(hierName!=null) eventBroker.post(ACTIVE_NODE_PATH, hierName);
Integer waves = persistedState.containsKey(SHOWN_WAVEFORM+"S")?Integer.parseInt(persistedState.get(SHOWN_WAVEFORM+"S")):0;
List<IWaveform<? extends IWaveformEvent>> res = new LinkedList<>();
for(int i=0; i<waves;i++){
@ -261,31 +247,22 @@ public class WaveformViewerPart {
}
private void updateAll() {
eventBroker.post(ACTIVE_DATABASE, database);
eventBroker.post(ACTIVE_WAVEFORMVIEW, this);
eventBroker.post(StatusBarControl.ZOOM_LEVEL, zoomLevel[txDisplay.getZoomLevel()]);
eventBroker.post(StatusBarControl.CURSOR_TIME, Long.toString(txDisplay.getCursorTime()/1000000)+"ns");
}
@Inject @Optional
public void getActiveNodeEvent(@UIEventTopic(WaveformViewerPart.ACTIVE_NODE) Object o, MPart activePart) {
if(o instanceof IHierNode){
activeNode=(IHierNode) o;
}
}
@Inject @Optional
public void getAddWaveformEvent(@UIEventTopic(WaveformViewerPart.ADD_WAVEFORM) Object o) {
Object sel = o==null?selectionService.getSelection():o;
if(sel instanceof List<?>)
for(Object el:((List<?>)sel)){
if(sel instanceof IStructuredSelection)
for(Object el:((IStructuredSelection)sel).toArray()){
if(el instanceof IWaveform<?>)
addStreamToList((IWaveform<?>) el);
addStreamToList((IWaveform<?>) el, false);
}
else if(sel instanceof IWaveform<?> )
addStreamToList((IWaveform<?>) sel);
}
/*
/*
@Inject
public void setWaveform(@Optional @Named( IServiceConstants.ACTIVE_SELECTION) IWaveform<?> waveform,
@Optional @Named( IServiceConstants.ACTIVE_PART) MPart part) {
@ -293,7 +270,7 @@ public class WaveformViewerPart {
txDisplay.setSelection(waveform==null?new StructuredSelection():new StructuredSelection(waveform));
}
}
*/
*/
protected boolean askIfToLoad(File txFile) {
if(txFile.exists() &&
MessageDialog.openQuestion(myParent.getDisplay().getActiveShell(), "Database open",
@ -326,17 +303,29 @@ public class WaveformViewerPart {
public IWaveformDb getModel() {
return database;
}
public IWaveformDb getDatabase() {
return database;
}
public void addStreamToList(IWaveform<? extends IWaveformEvent> obj){
txDisplay.getStreamList().add(obj);
public void addStreamToList(IWaveform<? extends IWaveformEvent> obj, boolean insert){
addStreamsToList(new IWaveform<?>[]{obj}, insert);
}
public void addStreamsToList(IWaveform<? extends IWaveformEvent>[] iWaveforms){
public void addStreamsToList(IWaveform<? extends IWaveformEvent>[] iWaveforms, boolean insert){
List<IWaveform<? extends IWaveformEvent>> streams= new LinkedList<>();
for(IWaveform<? extends IWaveformEvent> stream:iWaveforms)
addStreamToList(stream);
streams.add(stream);
IStructuredSelection selection = (IStructuredSelection) txDisplay.getSelection();
if(selection.size()==0)
txDisplay.getStreamList().addAll(streams);
else {
IWaveform<?> selectedStream = (selection.getFirstElement() instanceof ITx)?
((ITx)selection.getFirstElement()).getStream():(IWaveform<?>)selection.getFirstElement();
int index = txDisplay.getStreamList().indexOf(selectedStream);
if(!insert) index++;
txDisplay.getStreamList().addAll(index, streams);
}
}
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> obj){
@ -379,5 +368,15 @@ public class WaveformViewerPart {
return txDisplay.getZoomLevel();
}
}
public ISelection getSelection() {
return txDisplay.getSelection();
}
public void setSelection(IStructuredSelection structuredSelection) {
txDisplay.setSelection(structuredSelection, true);
}
public String getScaledTime(Long time) {
return txDisplay.getScaledTime(time);
}
}

View File

@ -16,13 +16,13 @@
<stringAttribute key="location" value="${workspace_loc}/../runtime-com.minres.scviewer.e4.application.product"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -clearPersistedState"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -clearPersistedState /Users/eyck/Workspaces/SCViewer/scv_tr_sqlite/my_db.vcd"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com.minres.scviewer.e4.application.product"/>
<stringAttribute key="productFile" value="/com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.product"/>
<stringAttribute key="selected_target_plugins" value="com.google.guava*10.0.1.v201203051515@default:default,com.google.guava*15.0.0.v201403281430@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet*3.0.0.v201112011016@default:default,javax.servlet*3.1.0.v201410161800@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.logging@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.codehaus.groovy*1.8.6.xx-201508121448-e45@default:default,org.codehaus.groovy*2.0.7.xx-201508121448-e45@default:default,org.codehaus.groovy*2.1.8.xx-201508121448-e45@default:default,org.codehaus.groovy*2.2.2.xx-201508121448-e45@default:default,org.codehaus.groovy*2.3.10.xx-201508121448-e45@default:default,org.codehaus.groovy*2.4.3.xx-201508121448-e45@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.text@default:default,org.eclipse.ui.cocoa@default:false,org.eclipse.ui.console@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.logging@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.text@default:default,org.eclipse.ui.cocoa@default:false,org.eclipse.ui.console@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:default,com.minres.scviewer.database.swt@default:default,com.minres.scviewer.database.text@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:default,com.minres.scviewer.e4.application@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>