fix handling of key short cuts

This commit is contained in:
Eyck Jentzsch 2021-11-18 12:55:23 +01:00
parent 9384d3278c
commit 9a59947e67
7 changed files with 86 additions and 72 deletions

View File

@ -179,6 +179,7 @@ public class WaveformCanvas extends Canvas {
}
public void setZoomLevel(int level, long centerTime) {
int maxLevel = findFitZoomLevel(maxTime);
if(level<0) {
if(level<-1) {
long cTime = getCursorPainters().get(0).getTime();
@ -186,11 +187,11 @@ public class WaveformCanvas extends Canvas {
level = findFitZoomLevel(time_diff);
centerTime = (centerTime>cTime?cTime:centerTime)+time_diff/2;
} else
level = findFitZoomLevel(maxTime);
level=maxLevel;
if(level<0) level = 0;
}
//FIXME: keep center if zoom-out and cursor is not in view
if(level<Constants.SCALE_MULTIPLIER.length*Constants.UNIT_STRING.length){
if(level<Constants.SCALE_MULTIPLIER.length*Constants.UNIT_STRING.length && level <= maxLevel){
int scale = level%Constants.SCALE_MULTIPLIER.length;
int unit = level/Constants.SCALE_MULTIPLIER.length;
this.scaleFactor = Constants.UNIT_MULTIPLIER[unit]*Constants.SCALE_MULTIPLIER[scale];

View File

@ -122,12 +122,6 @@ public class WaveformView implements IWaveformView {
protected ObservableList<TrackEntry> streams;
private boolean waveformsContainTx=false;
public boolean isWaveformsContainTx() {
return waveformsContainTx;
}
int selectedMarker = 0;
private int tracksVerticalHeight;
@ -166,8 +160,7 @@ public class WaveformView implements IWaveformView {
: streams.subList(firstIdx, lastIdx + 1);
setSelection(new StructuredSelection(res), (e.stateMask & SWT.CTRL) != 0, false);
} else
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0,
false);
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
} else {
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false);
}
@ -295,8 +288,15 @@ public class WaveformView implements IWaveformView {
@Override
public void handleEvent(Event e) {
switch (e.type) {
// case SWT.MouseWheel:
// break;
case SWT.MouseWheel:
if((e.stateMask & SWT.CTRL) != 0) {
int zoom = waveformCanvas.getZoomLevel();
if(e.count<0)
waveformCanvas.setZoomLevel(zoom+1);
else
waveformCanvas.setZoomLevel(zoom-1);
}
break;
case SWT.MouseDown:
start = new Point(e.x, e.y);
end = new Point(e.x, e.y);
@ -469,6 +469,17 @@ public class WaveformView implements IWaveformView {
toolTipHandler = new ToolTipHandler(parent.getShell());
toolTipHandler.activateHoverHelp(waveformCanvas);
// This is the filter that prevents it
getControl().getDisplay().addFilter(SWT.MouseWheel, new Listener() {
@Override
public void handleEvent(Event e) {
// Check if it's the correct widget
if((e.widget.equals(waveformCanvas) || e.widget.equals(this)) && (e.stateMask & SWT.CTRL) != 0) {
waveformMouseListener.handleEvent(e);
e.doit = false;
}
}
});
}
private void createTextPane(Composite namePane, String text) {
@ -518,7 +529,6 @@ 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;
@ -526,7 +536,6 @@ 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);
@ -762,27 +771,30 @@ public class WaveformView implements IWaveformView {
if (!add)
currentWaveformSelection.clear();
List<?> selList = sel.toList();
if (selList.get(0) instanceof ITx) {
ITx txSel = (ITx) selList.get(0);
TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry
? (TrackEntry) selList.get(1)
: null;
if (trackEntry == null) {
trackEntry = getEntryFor(txSel);
if (trackEntry == null && addIfNeeded) {
trackEntry = new TrackEntry(txSel.getStream(), styleProvider);
streams.add(trackEntry);
for(Object o: selList) {
if (o instanceof ITx) {
ITx txSel = (ITx) o;
TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry
? (TrackEntry) selList.get(1)
: null;
if (trackEntry == null) {
trackEntry = getEntryFor(txSel);
if (trackEntry == null && addIfNeeded) {
trackEntry = new TrackEntry(txSel.getStream(), styleProvider);
streams.add(trackEntry);
}
}
currentTxSelection = txSel;
currentWaveformSelection.clear();
currentWaveformSelection.add(trackEntry);
selectionChanged = true;
} else if (o instanceof TrackEntry) {
TrackEntry e = (TrackEntry)o;
if(!currentWaveformSelection.contains(e))
currentWaveformSelection.add(e);
selectionChanged = true;
}
currentTxSelection = txSel;
currentWaveformSelection.clear();
currentWaveformSelection.add(trackEntry);
selectionChanged = true;
} else if (selList.size() == 1 && selList.get(0) instanceof TrackEntry) {
currentWaveformSelection.add((TrackEntry) selList.get(0));
if (currentTxSelection != null)
currentTxSelection = null;
selectionChanged = true;
}
}
} else {
@ -1563,4 +1575,9 @@ public class WaveformView implements IWaveformView {
getStreamList().add(idx, e);
return e;
}
public boolean waveformsContainsTx() {
return streams.stream().filter(e -> e.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent();
}
}

View File

@ -12,18 +12,19 @@
<children xsi:type="basic:Part" xmi:id="_hXh-kEYFEeyPM8G0E2EYww" elementId="com.minres.scviewer.e4.application.dialog.onlinehelp" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.HelpDialog" label="SCViewer Online Help" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA" closeable="true"/>
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Re-load Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" mnemonics="M1+R" command="_srACsBkREeudD5MqrWoETQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Re-load Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" mnemonics="" command="_srACsBkREeudD5MqrWoETQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_e7MOYJedEeW09eyIbHsdvg" elementId="" label="Load active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
<parameters xmi:id="_4vtYgJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.30" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGwnNmEeWBq8z1Dv39LA" label="Save active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/script_save.png" command="_7-AIMJebEeW09eyIbHsdvg">
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGwnNmEeWBq8z1Dv39LA" label="Save active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/script_save.png" mnemonics="" command="_7-AIMJebEeW09eyIbHsdvg">
<parameters xmi:id="_61QIsJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.31" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="store"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGw3NmEeWBq8z1Dv39LA" label="Quit" command="_95PfvHNmEeWBq8z1Dv39LA"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_ZyHC0HgvEeWwZ-9vrAR2UQ" elementId="" label="Edit">
<children xsi:type="menu:HandledMenuItem" xmi:id="_cPlx4HgvEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.delete" label="Delete" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_FiwZcEhdEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.delete" label="Delete" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" command="_WUZ2wHXHEeWwZ-9vrAR2UQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_cPlx4HgvEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.delete" label="Select All" iconURI="" command="_bV-TMHXHEeWwZ-9vrAR2UQ"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_XmZY4HchEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.menu.navigate" label="Navigate">
<children xsi:type="menu:Menu" xmi:id="_VCn_cHgwEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.menu.waveform" label="Waveform ...">
@ -109,10 +110,10 @@
<parameters xmi:id="_5DrGQXf4EeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.fit" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="fit"/>
</children>
<children xsi:type="menu:ToolBarSeparator" xmi:id="_p1AvUHcqEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.toolbarseparator.1"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_XMQPAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomin" label="Zoom in" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magnifier_zoom_in.png" tooltip="Zoom in by a factor of 3" command="_693GoHcqEeWwZ-9vrAR2UQ">
<children xsi:type="menu:HandledToolItem" xmi:id="_XMQPAHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomin" label="Zoom in" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magnifier_zoom_in.png" tooltip="Zoom in" command="_693GoHcqEeWwZ-9vrAR2UQ">
<parameters xmi:id="_fi5w4HcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.in" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
</children>
<children xsi:type="menu:HandledToolItem" xmi:id="_XqTc8HcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomout" label="Zoom out" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magifier_zoom_out.png" tooltip="Zoom out by a factor of 3" command="_693GoHcqEeWwZ-9vrAR2UQ">
<children xsi:type="menu:HandledToolItem" xmi:id="_XqTc8HcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledtoolitem.zoomout" label="Zoom out" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/magifier_zoom_out.png" tooltip="Zoom out" command="_693GoHcqEeWwZ-9vrAR2UQ">
<parameters xmi:id="_d7OBYHcrEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.parameter.out" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
</children>
</children>
@ -157,16 +158,6 @@
<tags>type:user</tags>
</bindings>
</bindingTables>
<bindingTables xmi:id="_zZFy0GVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.waveform" bindingContext="_q4VSsGVNEeqSQM-A6dw9ig">
<bindings xmi:id="_1o3dEGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_in" keySequence="M1++" command="_693GoHcqEeWwZ-9vrAR2UQ">
<tags>type:user</tags>
<parameters xmi:id="_53UagGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.33" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
</bindings>
<bindings xmi:id="_8i3awGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_out" keySequence="M1+-" command="_693GoHcqEeWwZ-9vrAR2UQ">
<tags>type:user</tags>
<parameters xmi:id="__UCh4GVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.34" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
</bindings>
</bindingTables>
<bindingTables xmi:id="_XullMGVOEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.window" bindingContext="_95PfunNmEeWBq8z1Dv39LA">
<bindings xmi:id="_95PfwnNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.load" keySequence="M1+L" command="_7-AIMJebEeW09eyIbHsdvg">
<tags>type:user</tags>
@ -182,20 +173,22 @@
<bindings xmi:id="_3PRIQGVPEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.open" keySequence="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA">
<tags>type:user</tags>
</bindings>
</bindingTables>
<bindingTables xmi:id="_mnMrUGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.0" bindingContext="_iQ3kQGVmEeqSQM-A6dw9ig">
<bindings xmi:id="_n9yDwGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.0" keySequence="M1+A" command="_bV-TMHXHEeWwZ-9vrAR2UQ">
<bindings xmi:id="_QcOn8EheEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.keybinding.1" keySequence="M1+A" command="_bV-TMHXHEeWwZ-9vrAR2UQ"/>
<bindings xmi:id="_1o3dEGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_in" keySequence="M1++" command="_693GoHcqEeWwZ-9vrAR2UQ">
<tags>type:user</tags>
<parameters xmi:id="_53UagGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.33" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="in"/>
</bindings>
<bindings xmi:id="_8i3awGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.zoom_out" keySequence="M1+-" command="_693GoHcqEeWwZ-9vrAR2UQ">
<tags>type:user</tags>
<parameters xmi:id="__UCh4GVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.34" name="com.minres.scviewer.e4.application.command.zoomcommand.parameter.level" value="out"/>
</bindings>
<bindings xmi:id="_KjmnsEheEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.keybinding.0" keySequence="M1+R" command="_srACsBkREeudD5MqrWoETQ"/>
</bindingTables>
<rootContext xmi:id="_95PfuXNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
<children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows">
<children xmi:id="_q4VSsGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.waveform" name="In Waveform Part"/>
<children xmi:id="_iQ3kQGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.indesignbrowser" name="In DesignBrowser"/>
</children>
<children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
<children xmi:id="_95Pfu3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
</rootContext>
<descriptors xmi:id="_KicY0HRMEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.partdescriptor.waveformviewer" label="SCViewer" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/scviewer.png" bindingContexts="_q4VSsGVNEeqSQM-A6dw9ig" allowMultiple="true" category="General" closeable="true" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformViewer">
<descriptors xmi:id="_KicY0HRMEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.partdescriptor.waveformviewer" label="SCViewer" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/scviewer.png" allowMultiple="true" category="General" closeable="true" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.WaveformViewer">
<tags>categoryTag:General</tags>
<handlers xmi:id="_BSIuEHacEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateEventCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateEvent" command="_79rx4HabEeWwZ-9vrAR2UQ"/>
<handlers xmi:id="_JpdGwHXKEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handler.navigateTransCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.NavigateTrans" command="_Gn3lEHXKEeWwZ-9vrAR2UQ"/>

View File

@ -19,25 +19,15 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import com.minres.scviewer.e4.application.parts.DesignBrowser;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class SelectAllHandler {
@Inject @Optional DesignBrowser designBrowser;
@Execute
public void execute(EPartService partService) {
if(designBrowser==null) designBrowser = getListPart(partService);
if(designBrowser!=null){
designBrowser.selectAllWaveforms();
}
MPart part = partService.getActivePart();
if(part.getObject() instanceof WaveformViewer)
((WaveformViewer) part.getObject()).selectAll();
}
protected DesignBrowser getListPart(EPartService partService){
MPart part = partService.getActivePart();
if(part.getObject() instanceof DesignBrowser)
return (DesignBrowser) part.getObject();
else
return null;
}
}

View File

@ -85,7 +85,7 @@ HelpDialog_2=Stop
HelpDialog_3=Refresh
HelpDialog_4=Go
HelpDialog_5=Address
HelpDialog_6=https://git.minres.com/VP-Tools/SCViewer/src/branch/master/README.md\#key-shortcuts
HelpDialog_6=https://minres.github.io/SCViewer#key-shortcuts
HelpDialog_7=Could not instantiate Browser:
marker=Marker
marker_text=Marker TExt

View File

@ -226,6 +226,10 @@ public class DesignBrowser {
}
});
}
public Control getControl() {
return top;
}
/**
* Creates the table composite.

View File

@ -337,6 +337,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
case SWT.ARROW_DOWN:
waveformPane.moveSelectedTrack(1);
return;
case 'a':
selectAll();
default:
break;
}
@ -1269,4 +1271,11 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
} catch (BackingStoreException e) {}
}
}
public void selectAll() {
List<TrackEntry> entries = waveformPane.getStreamList();
ISelection sel = new StructuredSelection(entries);
waveformPane.setSelection(sel);
designBrowser.selectAllWaveforms();
}
}