From f4b03cb0e6548b6c20f1c2de1f80b4baf099d2e5 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Nov 2021 21:20:25 +0100 Subject: [PATCH] extend zoom handling (#70) and hide tx property panes (#58) --- .../ui/swt/internal/WaveformCanvas.java | 12 +- .../ui/swt/internal/WaveformView.java | 26 +- .../Application.e4xmi | 20 +- .../icons/application_side_contract.png | Bin 0 -> 547 bytes .../icons/application_side_expand.png | Bin 0 -> 581 bytes .../icons/zoom_fit.png | Bin 0 -> 6116 bytes .../icons/zoom_full.png | Bin 0 -> 6379 bytes .../scviewer/e4/application/Messages.java | 1 + .../application/handlers/EnableTxDetails.java | 57 +++ .../e4/application/handlers/ZoomHandler.java | 2 + .../e4/application/messages.properties | 1 + .../e4/application/parts/WaveformViewer.java | 343 ++++++++++-------- .../preferences/DefaultValuesInitializer.java | 1 + .../preferences/PreferenceConstants.java | 5 +- .../preferences/SCViewerPreferencesPage.java | 2 + 15 files changed, 305 insertions(+), 165 deletions(-) create mode 100644 plugins/com.minres.scviewer.e4.application/icons/application_side_contract.png create mode 100644 plugins/com.minres.scviewer.e4.application/icons/application_side_expand.png create mode 100644 plugins/com.minres.scviewer.e4.application/icons/zoom_fit.png create mode 100644 plugins/com.minres.scviewer.e4.application/icons/zoom_full.png create mode 100644 plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableTxDetails.java diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java index c3839c6..05bf89e 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java @@ -180,7 +180,13 @@ public class WaveformCanvas extends Canvas { public void setZoomLevel(int level, long centerTime) { if(level<0) { - level = findFitZoomLevel(); + if(level<-1) { + long cTime = getCursorPainters().get(0).getTime(); + long time_diff = centerTime>cTime?centerTime-cTime:cTime-centerTime; + level = findFitZoomLevel(time_diff); + centerTime = (centerTime>cTime?cTime:centerTime)+time_diff/2; + } else + level = findFitZoomLevel(maxTime); if(level<0) level = 0; } //FIXME: keep center if zoom-out and cursor is not in view @@ -211,7 +217,7 @@ public class WaveformCanvas extends Canvas { } } - private int findFitZoomLevel() { + private int findFitZoomLevel(long timeRange) { //get area actually capable of displaying data, i.e. area of the receiver which is capable of displaying data Rectangle clientArea = getClientArea(); long clientAreaWidth = clientArea.width; @@ -221,7 +227,7 @@ public class WaveformCanvas extends Canvas { for (int multiplier=0; multiplier= maxTime) + if(scaleFactor*clientAreaWidth >= timeRange) return tempLevel; } magnitude_factor*=1000; diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java index e1984fd..d4cf7cd 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java @@ -125,6 +125,12 @@ public class WaveformView implements IWaveformView { protected ObservableList streams; + private boolean waveformsContainTx=false; + + public boolean isWaveformsContainTx() { + return waveformsContainTx; + } + int selectedMarker = 0; private int tracksVerticalHeight; @@ -515,6 +521,7 @@ public class WaveformView implements IWaveformView { boolean even = true; TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); tl.setFont(styleProvider.getNameFont()); + waveformsContainTx=false; for (TrackEntry streamEntry : streams) { streamEntry.height = styleProvider.getTrackHeight(); streamEntry.vOffset = tracksVerticalHeight; @@ -522,6 +529,7 @@ public class WaveformView implements IWaveformView { streamEntry.currentValue = ""; streamEntry.height *= streamEntry.waveform.getRowCount(); painter = new StreamPainter(waveformCanvas, even, streamEntry); + waveformsContainTx=true; } else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) { streamEntry.currentValue = "---"; painter = new SignalPainter(waveformCanvas, even, streamEntry); @@ -1147,8 +1155,12 @@ public class WaveformView implements IWaveformView { */ @Override public void setZoomLevel(int scale) { - waveformCanvas.setZoomLevel(scale); - waveformCanvas.reveal(getCursorTime()); + if(scale<-1) { + waveformCanvas.setZoomLevel(scale, getMarkerTime(selectedMarker)); + } else { + waveformCanvas.setZoomLevel(scale); + waveformCanvas.reveal(getCursorTime()); + } } /* @@ -1554,14 +1566,4 @@ public class WaveformView implements IWaveformView { getStreamList().add(idx, e); return e; } - - - - - - - - - - } diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi index 85f4ea6..90b71f5 100644 --- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi +++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi @@ -102,19 +102,25 @@ - - + + + + + - + - + - + + EnableTxDetails + + EnableHover @@ -137,11 +143,12 @@ - + + type:user @@ -284,6 +291,7 @@ + diff --git a/plugins/com.minres.scviewer.e4.application/icons/application_side_contract.png b/plugins/com.minres.scviewer.e4.application/icons/application_side_contract.png new file mode 100644 index 0000000000000000000000000000000000000000..3585f94d611ca752a2e627eec6d07f8203c29466 GIT binary patch literal 547 zcmV+;0^I$HP)xhBK?{PAT#LZ1hW-T!t|5p9p`b~K3L-2ju*E^JkQ)1ep^i@O zO=b{e1r;|mMRr4XdiVLhU+?-1LR>b8k4JEKb|Q?7&0alocKG31%X{1b370S#E=Mlh z47uZGm_+aH)LdQtc4J|(HeC##9-i7&?TP(Wwxg%nvMFG?XeE!WwO?%4dh*C0g`0Ef zLWe*W2m~ULJ9D?Vcyg2zhfmSB_aH?q_}l12oh-VGO(x^z>t|%^tu|H~?#@1A}DkjYKCU z+(ih1ZZ45UNo*=A1>;x7$x=HZ6aOQ3vM@3>JKKNsNKIzQgqa};O9@HH9hc$e$c0Nt lWUm$`Yv+TzvlEdW`VF>D22IH@9z*~D002ovPDHLkV1mW`@~!{? literal 0 HcmV?d00001 diff --git a/plugins/com.minres.scviewer.e4.application/icons/application_side_expand.png b/plugins/com.minres.scviewer.e4.application/icons/application_side_expand.png new file mode 100644 index 0000000000000000000000000000000000000000..030cf7c37839cc02c5d08cb35de9f62640063c88 GIT binary patch literal 581 zcmV-L0=oT)P)bXLFrOI}#XAMrnzM!yjS$@!NeFNp5HyTkm?RpyuK%q>=#nO`L` zH==;V1|c9pf>tvp`m*qu(YM#h+5@Fh#;&%E$O|J1=7!iLIYm)$u;VZno}ZxjRuP@|>+C(Q4%^EH7|#@HX#1eW147;PK_BBq1TB ztSj<@D99YKNph?(W`E3bY~OK?cAwzMa0QZtGz8KlA(A^$=I%s7L~>CS1&w->X#C+#Snv+#Q#Y8#3W?Shv&pgYxkM5>5!j*M^V=GM TxI=}Z00000NkvXXu0mjfz>*Jk literal 0 HcmV?d00001 diff --git a/plugins/com.minres.scviewer.e4.application/icons/zoom_fit.png b/plugins/com.minres.scviewer.e4.application/icons/zoom_fit.png new file mode 100644 index 0000000000000000000000000000000000000000..5a28592de793eda06c5f74960f8e0758ded5d949 GIT binary patch literal 6116 zcmeHKc|25Y`=3d&tMEuv#x9K6XUt^ZG8jp+gmTQBVPqCFV@)Mx7g0}Ao`|PZA|^vkz?-}i%-}_IW&+q-OnK@_9xt8yBU*GGx@B5r&SC_SN(yG!h7)*}p zVCx3`FA*J*i=eam#3uj-TSSO<_Y%4R5eOci%VdRs2w@ZtM1YYjCJYw&Pl>1Z!CrmY zkNrx5h1$w>p2gQ5#mTda&v#8dIik^$ z>a(gOyenax*z2YKkm!mxQWIqLFM0cLt3{^vY);tto2NsI-^C41#zw7};Po2aAG}KG zZplb9jI?Yek3J2nSl-_qsb*ts-nf7J_}#08{L0sD_}P1@#WZAE+nFa_CN+3`e}QQxEuyr08H!oAH@<^HSArdjic~6H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`ZT9x~6;cg=6sr+WYqlnz`)V*4&(ve*1z}VN0dT9)qA}!J{QJ z*S+RN#*R*io{4#s^7~rT#L3U42bS>Sx|g_=R_(1fqb@Ax!_7B@m%skk?^m7}+g!P9 zr>p3eckn#Veg08p?S7tDPdSI{mO| z(o<~hW!0VKOzSBUq&k`hd<^)5#S#0mL9^}hA=f!%>Xi>h{)F4*sVRs=EM?!6CQ`b! z&)q_oBDT8A?dzey>1#XtLQ;=h>~NcTI<>{7XPcnBn3-7jr}eh7Z|!{5HksXfjo{71 zs%$!Ub2yqso@_kwd8W6xuCQX(s{@9=E_I@$I4*_a2S*FZC?3H1nFeG>F}>_R#8!pp zeR*XSRonVJS6@n~+qY2;nyi?CeF^l5AJbggx+9>vrs?HE0x>mZlGF{={JIn?aK*oF VTB&E)8|;3Ft)-(ync3cie*?9IC^7&5 literal 0 HcmV?d00001 diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java index 574a1bf..3ca4467 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java @@ -24,6 +24,7 @@ public class Messages extends NLS { public static String SCViewerPreferencesPage_0; public static String SCViewerPreferencesPage_1; public static String SCViewerPreferencesPage_2; + public static String SCViewerPreferencesPage_3; public static String StatusBarControl_1; public static String StatusBarControl_2; public static String StatusBarControl_3; diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableTxDetails.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableTxDetails.java new file mode 100644 index 0000000..217c1dc --- /dev/null +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableTxDetails.java @@ -0,0 +1,57 @@ + +package com.minres.scviewer.e4.application.handlers; + +import java.util.LinkedList; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.core.di.extensions.Preference; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.model.application.ui.menu.MHandledItem; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.EPartService; +import org.osgi.service.prefs.BackingStoreException; + +import com.minres.scviewer.e4.application.preferences.PreferenceConstants; + +@SuppressWarnings("restriction") +public class EnableTxDetails { + static final String TAG_NAME = "EnableTxDetails"; //$NON-NLS-1$ + + static final String ICON_DISABLED = "platform:/plugin/com.minres.scviewer.e4.application/icons/application_side_expand.png"; //$NON-NLS-1$ + static final String ICON_ENABLED = "platform:/plugin/com.minres.scviewer.e4.application/icons/application_side_contract.png"; //$NON-NLS-1$ + static final String TOOLTIP_DISABLED = "Show tx details parts"; + static final String TOOLTIP_ENABLED = "Hide tx details parts"; + + @Inject + MApplication application; + + @Inject + EPartService partService; + + @Inject + @Optional + public void reactOnShowHoverChange(EModelService modelService, @Preference(value = PreferenceConstants.SHOW_TX_DETAILS) Boolean show) { + List tags = new LinkedList<>(); + tags.add(TAG_NAME); + List elements = modelService.findElements(application, null, MHandledItem.class, tags ); + for( MHandledItem hi : elements ){ + hi.setSelected(show); + hi.setIconURI(show?ICON_ENABLED:ICON_DISABLED); + hi.setTooltip(show?TOOLTIP_ENABLED:TOOLTIP_DISABLED); + } + } + + @Execute + public void execute(MHandledItem handledItem, @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs ) { + try { + prefs.putBoolean(PreferenceConstants.SHOW_TX_DETAILS, handledItem.isSelected()); + prefs.flush(); + } catch (BackingStoreException e) {} + } + +} \ No newline at end of file diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java index 4bae012..a632a23 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/ZoomHandler.java @@ -42,6 +42,8 @@ public class ZoomHandler { waveformViewerPart.setZoomLevel(zoomLevel+1); else if("fit".equalsIgnoreCase(level)) //$NON-NLS-1$ waveformViewerPart.setZoomFit(); + else if("full".equalsIgnoreCase(level)) //$NON-NLS-1$ + waveformViewerPart.setZoomFull(); } } diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties index 4642017..a8fff7f 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties @@ -18,6 +18,7 @@ ResourceManager_0=Wrong decorate corner SCViewerPreferencesPage_0=Check for changed database SCViewerPreferencesPage_1=Show hover window in waveform SCViewerPreferencesPage_2=Waveform track height +SCViewerPreferencesPage_3=Show tx details in waveform StatusBarControl_1=Currently running: StatusBarControl_2=\nLast task: StatusBarControl_3=Currently running: diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 387dae6..076f682 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -74,6 +74,7 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Widget; +import org.osgi.service.prefs.BackingStoreException; import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.IHierNode; @@ -82,6 +83,7 @@ import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDbFactory; import com.minres.scviewer.database.RelationType; import com.minres.scviewer.database.RelationTypeFactory; +import com.minres.scviewer.database.WaveformType; import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.tx.ITxAttribute; import com.minres.scviewer.database.tx.ITxEvent; @@ -117,35 +119,38 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis /** The Constant DATABASE_FILE. */ protected static final String DATABASE_FILE = "DATABASE_FILE"; //$NON-NLS-1$ - + /** The Constant SHOWN_WAVEFORM. */ protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; //$NON-NLS-1$ - + protected static final String VALUE_DISPLAY = ".VALUE_DISPLAY"; //$NON-NLS-1$ - + protected static final String WAVE_DISPLAY = ".WAVE_DISPLAY"; //$NON-NLS-1$ - + /** The Constant SHOWN_CURSOR. */ protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$ - + /** The Constant ZOOM_LEVEL. */ protected static final String ZOOM_LEVEL = "ZOOM_LEVEL"; //$NON-NLS-1$ /** The Constant BASE_LINE_TIME. */ protected static final String BASE_LINE_TIME = "BASE_LINE_TIME"; //$NON-NLS-1$ - + /** The Constant SELECTED_TX_ID. */ protected static final String SELECTED_TX_ID = "SELECTED_TX_ID"; //$NON-NLS-1$ /** The Constant SELECTED_TRACKENTRY_NAME. */ protected static final String SELECTED_TRACKENTRY_NAME = "SELECTED_TRACKENTRY_NAME"; //$NON-NLS-1$ - + /** The Constant WAVEFORM_SELECTED. */ protected static final String WAVEFORM_SELECTED = ".WAVEFORM_SELECTED"; //$NON-NLS-1$ - + /** The Constant FILE_CHECK_INTERVAL. */ protected static final long FILE_CHECK_INTERVAL = 60000; - + + /** The Constant TX_DETAILS_SHOWN. */ + protected static final String TX_DETAILS_SHOWN = "TX_DETAILS_SHOWN"; //$NON-NLS-1$ + /** The zoom level. */ private String[] zoomLevel; @@ -156,19 +161,19 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave"; //$NON-NLS-1$ private static final String MENU_CONTEXT = "com.minres.scviewer.e4.application.popupmenu.wavecontext"; //$NON-NLS-1$ - + /** The number of active DisposeListeners */ private int disposeListenerNumber = 0; - + /** The factory. */ WaveformViewFactory factory = new WaveformViewFactory(); DesignBrowser browser = null; - + TransactionDetails detailsView = null; - + TransactionListView transactionList = null; - + /** The waveform pane. */ private IWaveformView waveformPane; @@ -211,7 +216,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis ArrayList filesToLoad = new ArrayList<>(); String partConfig = ""; - + /** The persisted state. */ Map persistedState; @@ -231,11 +236,16 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis IModificationChecker fileChecker; @Inject IWaveformDbFactory dbFactory; - + @Inject Composite parent; - + private boolean showHover; + @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE, value = PreferenceConstants.SHOW_TX_DETAILS) Boolean blah; + + private SashForm topSash = null; + private SashForm middleSash = null; + /** * Creates the composite. * @@ -246,7 +256,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis @PostConstruct public void createComposite(MPart part, EMenuService menuService, @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs, @Preference(value = PreferenceConstants.SHOW_HOVER) Boolean hover) { disposeListenerNumber += 1; - + myPart = part; myParent = parent; store=prefs; @@ -258,14 +268,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } }); parent.setLayout(new FillLayout(SWT.HORIZONTAL)); - + IEclipseContext ctx = myPart.getContext(); ctx.set(WaveformViewer.class, this); ctx.set(IWaveformDb.class, database); - SashForm topSash = new SashForm(parent, SWT.BORDER | SWT.SMOOTH | SWT.HORIZONTAL); + topSash = new SashForm(parent, SWT.BORDER | SWT.SMOOTH | SWT.HORIZONTAL); Composite left = new Composite(topSash, SWT.NONE); - SashForm middleSash = new SashForm(topSash, SWT.BORDER | SWT.SMOOTH | SWT.VERTICAL); + middleSash = new SashForm(topSash, SWT.BORDER | SWT.SMOOTH | SWT.VERTICAL); Composite right = new Composite(topSash, SWT.NONE); topSash.setWeights(new int[] {20, 60, 20}); @@ -275,101 +285,101 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis ctx.set(Composite.class, left); browser = ContextInjectionFactory.make(DesignBrowser.class, ctx); - + ctx.set(Composite.class, right); detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx); waveformPane = factory.createPanel(middleTop); - + ctx.set(Composite.class, middleBottom); transactionList = ContextInjectionFactory.make(TransactionListView.class, ctx); - + waveformPane.setMaxTime(0); //set selection to empty selection when opening a new waveformPane selectionService.setSelection(new StructuredSelection()); - + waveformPane.addPropertyChangeListener(IWaveformView.CURSOR_PROPERTY, evt -> { - Long time = (Long) evt.getNewValue(); - eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time)); - long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId()); - eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker)); + Long time = (Long) evt.getNewValue(); + eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time)); + long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId()); + eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker)); }); waveformPane.addPropertyChangeListener(IWaveformView.MARKER_PROPERTY, evt -> { - Long time = (Long) evt.getNewValue(); - eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(time)); - long cursor = waveformPane.getCursorTime(); - eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time)); + Long time = (Long) evt.getNewValue(); + eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(time)); + long cursor = waveformPane.getCursorTime(); + eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time)); }); - + waveformPane.addSelectionChangedListener(event -> { - if (event.getSelection() instanceof IStructuredSelection) { - selectionService.setSelection(event.getSelection()); - } + if (event.getSelection() instanceof IStructuredSelection) { + selectionService.setSelection(event.getSelection()); + } }); waveformPane.getWaveformControl().addListener(SWT.KeyDown, e -> { - if((e.stateMask&SWT.MOD3)!=0) { // Alt key - } else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd - int zoomlevel = waveformPane.getZoomLevel(); - switch(e.keyCode) { - case '+': - case SWT.KEYPAD_ADD: - if(zoomlevel>0) - waveformPane.setZoomLevel(zoomlevel-1); - return; - case '-': - case SWT.KEYPAD_SUBTRACT: - if(zoomlevel0) + waveformPane.setZoomLevel(zoomlevel-1); + return; + case '-': + case SWT.KEYPAD_SUBTRACT: + if(zoomlevel(); @@ -461,8 +471,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis valueCol.pack(); table.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT)); parent.addPaintListener( e -> { - Rectangle area = parent.getClientArea(); - valueCol.setWidth(area.width - nameCol.getWidth()); + Rectangle area = parent.getClientArea(); + valueCol.setWidth(area.width - nameCol.getWidth()); }); parent.addFocusListener(FocusListener.focusGainedAdapter(e -> table.setFocus())); return true; @@ -484,21 +494,28 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } }); waveformPane.setStyleProvider(new WaveformStyleProvider(store)); + showTxDetails(false); } @Inject @Optional public void reactOnPrefsChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs) { prefs.addPreferenceChangeListener(this); - + } - + @Inject @Optional public void reactOnShowHoverChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE, value = PreferenceConstants.SHOW_HOVER) Boolean hover) { showHover=hover; } - + + @Inject + @Optional + public void reactOnShowTxDetailsChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE, value = PreferenceConstants.SHOW_TX_DETAILS) Boolean show) { + showTxDetails(show); + } + @Inject @Optional public void reactOnReloadDatabaseChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE, value = PreferenceConstants.DATABASE_RELOAD) Boolean checkForUpdates) { @@ -568,7 +585,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis if (monitor.isCanceled()) throw new OperationCanceledException(Messages.WaveformViewer_14); - + IStatus result = jobGroup.getResult(); if( (!result.isMultiStatus() && result.getCode() != Status.OK_STATUS.getCode() ) || (result.isMultiStatus() && result.getChildren().length > 0 && result.getChildren()[0].getCode() != Status.OK_STATUS.getCode() ) ){ @@ -605,10 +622,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis public void fileChanged(List file) { final Display display = myParent.getDisplay(); display.asyncExec(() -> { - if (MessageDialog.openQuestion(display.getActiveShell(), Messages.WaveformViewer_17, - Messages.WaveformViewer_18)) { - reloadDatabase(); - } + if (MessageDialog.openQuestion(display.getActiveShell(), Messages.WaveformViewer_17, + Messages.WaveformViewer_18)) { + reloadDatabase(); + } }); fileMonitor.removeFileChangeListener(this); } @@ -684,14 +701,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis saveWaveformViewerState(persistingState); Properties props = new Properties(); props.putAll(persistingState); - + try (FileOutputStream out = new FileOutputStream(fileName)) { props.store(out, "Written by SCViewer"); //$NON-NLS-1$ } catch (IOException e) { e.printStackTrace(); } } - + public void loadState(String fileName){ //clear old streams before loading tab settings if(!waveformPane.getStreamList().isEmpty()) { @@ -709,7 +726,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis e.printStackTrace(); } } - + /** * Save waveform viewer state. * @@ -734,7 +751,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } persistingState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel())); persistingState.put(BASE_LINE_TIME, Long.toString(waveformPane.getBaselineTime())); - + // get selected transaction of a stream ISelection selection = waveformPane.getSelection(); if (!selection.isEmpty()) { @@ -749,24 +766,25 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis persistingState.put(SELECTED_TRACKENTRY_NAME, name); } } + persistingState.put(TX_DETAILS_SHOWN, Boolean.toString(store.getBoolean(PreferenceConstants.SHOW_TX_DETAILS, false))); } protected List getISelection(ISelection selection){ - List result = new LinkedList<> (); + List result = new LinkedList<> (); - if ( selection instanceof IStructuredSelection ) { - Iterator i = ((IStructuredSelection)selection).iterator(); - while (i.hasNext()){ - Object o = i.next (); - if (o == null) { - continue; - } - result.add(o); - } - } - return result; + if ( selection instanceof IStructuredSelection ) { + Iterator i = ((IStructuredSelection)selection).iterator(); + while (i.hasNext()){ + Object o = i.next (); + if (o == null) { + continue; + } + result.add(o); + } + } + return result; } - + /** * Restore waveform viewer state. * @@ -823,18 +841,24 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis String trackentryName = state.get(SELECTED_TRACKENTRY_NAME); //get TrackEntry Object based on name and TX Object by id and put into selectionList trackEntries.stream().filter(e->trackentryName.equals(e.waveform.getFullName())).forEach(trackEntry -> - trackEntry.waveform.getEvents().entrySet().stream() - .map(e->e.events) - .filter(Objects::nonNull) - .forEach(entries-> - Arrays.stream(entries) - .filter(e->e instanceof ITxEvent && txId.equals(((ITxEvent)e).getTransaction().getId())) - .forEach(event -> - waveformPane.setSelection(new StructuredSelection( - new Object[] {((ITxEvent)event).getTransaction(), trackEntry})) + trackEntry.waveform.getEvents().entrySet().stream() + .map(e->e.events) + .filter(Objects::nonNull) + .forEach(entries-> + Arrays.stream(entries) + .filter(e->e instanceof ITxEvent && txId.equals(((ITxEvent)e).getTransaction().getId())) + .forEach(event -> + waveformPane.setSelection(new StructuredSelection( + new Object[] {((ITxEvent)event).getTransaction(), trackEntry})) ) - ) - ); + ) + ); + } catch (NumberFormatException e) { + } + } + if (state.containsKey(TX_DETAILS_SHOWN)) { + try { + showTxDetails(Boolean.parseBoolean(state.get(TX_DETAILS_SHOWN))); } catch (NumberFormatException e) { } } @@ -970,15 +994,18 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } } + showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent()); setFocus(); } public void removeSelectedStreamsFromList() { waveformPane.deleteSelectedTracks(); + showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent()); } public void removeSelectedStreamFromList() { waveformPane.deleteSelectedTracks(); + showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent()); } /** * Move selected. @@ -989,7 +1016,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.moveSelectedTrack(i); } - + /** * Move selection. * @@ -1036,6 +1063,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis * Sets the zoom fit. */ public void setZoomFit() { + waveformPane.setZoomLevel(-2); + updateAll(); + } + + /** + * Sets the zoom fit. + */ + public void setZoomFull() { waveformPane.setZoomLevel(-1); updateAll(); } @@ -1181,7 +1216,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType); navigationRelationType=relationType; } - + public void update() { waveformPane.update(); } @@ -1200,17 +1235,39 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis * * @param e */ - public void widgetDisposed(DisposeEvent e) { - disposeListenerNumber -= 1; - if( disposeListenerNumber == 0) { //if the last tab is closed, reset statusbar + public void widgetDisposed(DisposeEvent e) { + disposeListenerNumber -= 1; + if( disposeListenerNumber == 0) { //if the last tab is closed, reset statusbar eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, null); eventBroker.post(WaveStatusBarControl.CURSOR_TIME, null); eventBroker.post(WaveStatusBarControl.MARKER_TIME, null); eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null); - } - } - + } + } + public void search(String propName, DataType type, String propValue) { transactionList.getControl().setSearchProps(propName, type, propValue); } + + public void showTxDetails(boolean show) { + if(middleSash==null || topSash==null || middleSash.isDisposed() || topSash.isDisposed()) + return; + if(show) { + middleSash.setWeights(new int[] {75, 25}); + topSash.setWeights(new int[] {20, 60, 20}); + } else { + middleSash.setWeights(new int[] {100, 0}); + topSash.setWeights(new int[] {20, 80, 0}); + + } + detailsView.getControl().setVisible(show); + transactionList.getControl().setVisible(show); + parent.requestLayout(); + if(store.getBoolean(PreferenceConstants.SHOW_TX_DETAILS, false) != show) { + store.putBoolean(PreferenceConstants.SHOW_TX_DETAILS, show); + try { + store.flush(); + } catch (BackingStoreException e) {} + } + } } \ No newline at end of file diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index 86692e3..930e6d7 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -68,6 +68,7 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { store.putBoolean(PreferenceConstants.DATABASE_RELOAD, true); store.putBoolean(PreferenceConstants.SHOW_HOVER, true); + store.putBoolean(PreferenceConstants.SHOW_TX_DETAILS, false); store.putInt(PreferenceConstants.TRACK_HEIGHT, 30); for (WaveformColors c : WaveformColors.values()) { store.put(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java index 8026c12..86fd48e 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java @@ -23,9 +23,12 @@ public class PreferenceConstants { /** The Constant DATABASE_RELOAD. */ public static final String DATABASE_RELOAD="databaseReload"; //$NON-NLS-1$ - /** The Constant DATABASE_RELOAD. */ + /** The Constant SHOW_HOVER. */ public static final String SHOW_HOVER="showWaveformHover"; //$NON-NLS-1$ + /** The Constant SHOW_TX_DETAILS. */ + public static final String SHOW_TX_DETAILS="showTxDetails"; //$NON-NLS-1$ + /** The Constant TRACK_HEIGHT. */ public static final String TRACK_HEIGHT="trackHeigth"; //$NON-NLS-1$ diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java index 0099795..f010c4d 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java @@ -39,6 +39,8 @@ public class SCViewerPreferencesPage extends FieldEditorPreferencePage { getFieldEditorParent())); addField(new BooleanFieldEditor(PreferenceConstants.SHOW_HOVER, Messages.SCViewerPreferencesPage_1, getFieldEditorParent())); + addField(new BooleanFieldEditor(PreferenceConstants.SHOW_TX_DETAILS, Messages.SCViewerPreferencesPage_3, + getFieldEditorParent())); addField(new IntegerFieldEditor(PreferenceConstants.TRACK_HEIGHT, Messages.SCViewerPreferencesPage_2, getFieldEditorParent()));