adds support for grouping waveform tracks
This commit is contained in:
1 parent
d46c02e991
commit
336aef269d
13 files changed
+591
-87
No files matched your search
@@ -23,6 +23,8 @@
|
||||
<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="_menu_edit_groupTracks" elementId="com.minres.scviewer.e4.application.menu.edit.groupTracks" label="Group tracks…" command="_command_groupTracks"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_menu_edit_ungroupTracks" elementId="com.minres.scviewer.e4.application.menu.edit.ungroupTracks" label="Ungroup tracks" command="_command_ungroupTracks"/>
|
||||
<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>
|
||||
@@ -101,6 +103,8 @@
|
||||
</children>
|
||||
</trimBars>
|
||||
</children>
|
||||
<handlers xmi:id="_handler_ungroupTracks" elementId="com.minres.scviewer.e4.application.handler.ungroupTracks" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.UngroupTracksHandler" command="_command_ungroupTracks"/>
|
||||
<handlers xmi:id="_handler_groupTracks" elementId="com.minres.scviewer.e4.application.handler.groupTracks" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.GroupTracksHandler" command="_command_groupTracks"/>
|
||||
<handlers xmi:id="_95PfvXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.quitCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.QuitHandler" command="_95PfvHNmEeWBq8z1Dv39LA"/>
|
||||
<handlers xmi:id="_95PfwXNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.openCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.OpenHandler" command="_95PfwHNmEeWBq8z1Dv39LA"/>
|
||||
<handlers xmi:id="_95PfxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handler.saveCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SaveHandler" command="_95Pfw3NmEeWBq8z1Dv39LA"/>
|
||||
@@ -126,6 +130,8 @@
|
||||
<bindings xmi:id="_2-008EhnEeyp3vLifEzGbQ" elementId="com.minres.scviewer.e4.application.keybinding.help" keySequence="F1" command="_RdUMoHCOEeyub8CfGE1sGA"/>
|
||||
</bindingTables>
|
||||
<bindingTables xmi:id="_XullMGVOEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.window" bindingContext="_95PfunNmEeWBq8z1Dv39LA">
|
||||
<bindings xmi:id="_binding_ungroupTracks" elementId="com.minres.scviewer.e4.application.keybinding.ungroupTracks" keySequence="M1+M2+G" command="_command_ungroupTracks"/>
|
||||
<bindings xmi:id="_binding_groupTracks" elementId="com.minres.scviewer.e4.application.keybinding.groupTracks" keySequence="M1+G" command="_command_groupTracks"/>
|
||||
<bindings xmi:id="_95PfwnNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.load" keySequence="M1+L" command="_7-AIMJebEeW09eyIbHsdvg">
|
||||
<tags>type:user</tags>
|
||||
<parameters xmi:id="_G_ulwGVPEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.parameter.35" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
|
||||
@@ -203,10 +209,12 @@
|
||||
<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>
|
||||
<children xsi:type="menu:MenuSeparator" xmi:id="_cxgs4Lc0Ee294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.menuseparator.1"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_menu_popup_groupTracks" elementId="com.minres.scviewer.e4.application.menu.popup.groupTracks" label="Group tracks…" command="_command_groupTracks"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_menu_popup_ungroupTracks" elementId="com.minres.scviewer.e4.application.menu.popup.ungroupTracks" label="Ungroup tracks" command="_command_ungroupTracks"/>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_NFfK0LcyEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.handledmenuitem.add_separator" label="Add separator above" command="_vYAOQLcxEe294PIiYLxpfA">
|
||||
<parameters xmi:id="_or7iYLcyEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.parameter.15" name="com.minres.scviewer.e4.application.commandparameter.add_separator" value="before"/>
|
||||
</children>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_Dj-FUBTJEe6ZlJc8qY5-Zw" elementId="com.minres.scviewer.e4.application.handledmenuitem.add_separator" label="Add separator below" command="_vYAOQLcxEe294PIiYLxpfA">
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_Dj-FUBTJEe6ZlJc8qY5-Zw" elementId="com.minres.scviewer.e4.application.handledmenuitem.add_separator" label="Add separator after last" command="_vYAOQLcxEe294PIiYLxpfA">
|
||||
<parameters xmi:id="_Dj-FURTJEe6ZlJc8qY5-Zw" elementId="com.minres.scviewer.e4.application.parameter.15" name="com.minres.scviewer.e4.application.commandparameter.add_separator" value="after"/>
|
||||
</children>
|
||||
<children xsi:type="menu:HandledMenuItem" xmi:id="_ecbWkLc0Ee294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.handledmenuitem.add_separator" visible="false" label="Add blank below" enabled="false" command="_vYAOQLcxEe294PIiYLxpfA">
|
||||
@@ -271,6 +279,8 @@
|
||||
<snippets xsi:type="basic:Window" xmi:id="_cg-28HClEeyNn6bZ9_VasA" elementId="com.minres.scviewer.e4.application.window.help_content" selectedElement="_cg-28XClEeyNn6bZ9_VasA" label="SCViewer Help Content" width="800" height="600">
|
||||
<children xsi:type="basic:Part" xmi:id="_cg-28XClEeyNn6bZ9_VasA" elementId="com.minres.scviewer.e4.application.part.container" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.HelpBrowser"/>
|
||||
</snippets>
|
||||
<commands xmi:id="_command_ungroupTracks" elementId="com.minres.scviewer.e4.application.command.ungroupTracks" commandName="Resolve group"/>
|
||||
<commands xmi:id="_command_groupTracks" elementId="com.minres.scviewer.e4.application.command.groupTracks" commandName="Group tracks…"/>
|
||||
<commands xmi:id="_95PfvHNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.exit" commandName="Quit Command"/>
|
||||
<commands xmi:id="_95PfwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.open" commandName="Open Command"/>
|
||||
<commands xmi:id="_95Pfw3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.save" commandName="Save Command"/>
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
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.EPartService;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class GroupTracksHandler {
|
||||
static WaveformViewer activeViewer(EPartService parts) {
|
||||
MPart part = parts == null ? null : parts.getActivePart();
|
||||
return part != null && part.getObject() instanceof WaveformViewer viewer ? viewer : null;
|
||||
}
|
||||
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService parts) {
|
||||
WaveformViewer viewer = activeViewer(parts);
|
||||
return viewer != null && viewer.canGroupSelectedTracks();
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void execute(EPartService parts, Shell shell) {
|
||||
WaveformViewer viewer = activeViewer(parts);
|
||||
if (viewer == null || !viewer.canGroupSelectedTracks()) return;
|
||||
String name = requestGroupName(shell);
|
||||
if (name != null) viewer.groupSelectedTracks(name);
|
||||
}
|
||||
|
||||
protected String requestGroupName(Shell shell) {
|
||||
InputDialog dialog = new InputDialog(shell, "Group tracks", "Group name", "Group",
|
||||
name -> name.isBlank() ? "Enter a group name" : null);
|
||||
return dialog.open() == Window.OK ? dialog.getValue() : null;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class UngroupTracksHandler {
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService parts) {
|
||||
WaveformViewer viewer = GroupTracksHandler.activeViewer(parts);
|
||||
return viewer != null && viewer.canUngroupSelectedTracks();
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void execute(EPartService parts) {
|
||||
WaveformViewer viewer = GroupTracksHandler.activeViewer(parts);
|
||||
if (viewer != null && viewer.canUngroupSelectedTracks()) viewer.ungroupSelectedTracks();
|
||||
}
|
||||
}
|
||||
+24
-2
@@ -37,7 +37,16 @@ public record ViewerSettings(List<Track> tracks, List<Long> cursors, Long scale,
|
||||
public static final String WAVEFORM_SELECTED = ".WAVEFORM_SELECTED";
|
||||
public static final String TX_DETAILS_SHOWN = "TX_DETAILS_SHOWN";
|
||||
|
||||
public record Track(String name, WaveformType type, ValueDisplay valueDisplay, WaveDisplay waveDisplay, boolean selected) {}
|
||||
/** Tracks are stored in preorder, including hidden descendants. PARENT is an index
|
||||
* into this list; it must refer to an earlier group, making cycles impossible.
|
||||
* Legacy entries have no parent or group flags and remain ordinary root tracks.
|
||||
*/
|
||||
public record Track(String name, WaveformType type, ValueDisplay valueDisplay, WaveDisplay waveDisplay,
|
||||
boolean selected, Integer parent, boolean group, boolean expanded) {
|
||||
public Track(String name, WaveformType type, ValueDisplay valueDisplay, WaveDisplay waveDisplay, boolean selected) {
|
||||
this(name, type, valueDisplay, waveDisplay, selected, null, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public ViewerSettings {
|
||||
tracks = List.copyOf(tracks);
|
||||
@@ -68,6 +77,11 @@ public record ViewerSettings(List<Track> tracks, List<Long> cursors, Long scale,
|
||||
Track track = tracks.get(i);
|
||||
String key = SHOWN_WAVEFORM + i;
|
||||
state.put(key, track.name());
|
||||
if (track.parent() != null) state.put(key + ".PARENT", track.parent().toString());
|
||||
if (track.group()) {
|
||||
state.put(key + ".GROUP", "true");
|
||||
state.put(key + ".EXPANDED", Boolean.toString(track.expanded()));
|
||||
}
|
||||
if (track.type() != null) state.put(key + WAVEFORM_TYPE, track.type().name());
|
||||
state.put(key + WAVEFORM_SELECTED, Boolean.toString(track.selected()));
|
||||
state.put(key + VALUE_DISPLAY, track.valueDisplay().name());
|
||||
@@ -100,10 +114,18 @@ public record ViewerSettings(List<Track> tracks, List<Long> cursors, Long scale,
|
||||
String name = required(state, key);
|
||||
WaveformType type = "TRANSACTION".equals(state.get(key + WAVEFORM_TYPE)) ? WaveformType.STREAM
|
||||
: enumeration(state, key + WAVEFORM_TYPE, WaveformType.class, null);
|
||||
Long parent = number(state, key + ".PARENT");
|
||||
if (parent != null && (parent < 0 || parent >= i || !tracks.get(parent.intValue()).group()))
|
||||
throw invalid(key + ".PARENT", "must reference an earlier group");
|
||||
boolean group = Boolean.TRUE.equals(bool(state, key + ".GROUP"));
|
||||
Boolean expanded = bool(state, key + ".EXPANDED");
|
||||
if (group && type != WaveformType.EMPTY) throw invalid(key + WAVEFORM_TYPE, "group must have EMPTY type");
|
||||
if (!group && expanded != null) throw invalid(key + ".EXPANDED", "requires a group");
|
||||
tracks.add(new Track(name, type,
|
||||
enumeration(state, key + VALUE_DISPLAY, ValueDisplay.class, ValueDisplay.DEFAULT),
|
||||
enumeration(state, key + WAVE_DISPLAY, WaveDisplay.class, WaveDisplay.DEFAULT),
|
||||
Boolean.TRUE.equals(bool(state, key + WAVEFORM_SELECTED))));
|
||||
Boolean.TRUE.equals(bool(state, key + WAVEFORM_SELECTED)),
|
||||
parent == null ? null : parent.intValue(), group, group && !Boolean.FALSE.equals(expanded)));
|
||||
}
|
||||
List<Long> cursors = new ArrayList<>();
|
||||
for (int i = 0, n = count(state, SHOWN_CURSOR + "S"); i < n; i++) {
|
||||
|
||||
+58
-10
@@ -626,10 +626,19 @@ public class WaveformViewer implements IPreferenceChangeListener, DisposeListene
|
||||
captureSettings().replaceState(state);
|
||||
}
|
||||
|
||||
private static void captureTracks(List<TrackEntry> entries, Integer parent, List<ViewerSettings.Track> result) {
|
||||
for (TrackEntry entry : entries) {
|
||||
int index = result.size();
|
||||
result.add(new ViewerSettings.Track(entry.waveform.getFullName(), entry.waveform.getType(),
|
||||
entry.valueDisplay, entry.waveDisplay, entry.selected, parent, entry.isGroup(),
|
||||
entry.hierState == TrackEntry.HierState.OPENED));
|
||||
if (entry.isGroup()) captureTracks(entry.waveforms, index, result);
|
||||
}
|
||||
}
|
||||
|
||||
private ViewerSettings captureSettings() {
|
||||
List<ViewerSettings.Track> tracks = waveformPane.getStreamList().stream()
|
||||
.map(t -> new ViewerSettings.Track(t.waveform.getFullName(), t.waveform.getType(),
|
||||
t.valueDisplay, t.waveDisplay, t.selected)).toList();
|
||||
List<ViewerSettings.Track> tracks = new ArrayList<>();
|
||||
captureTracks(waveformPane.getStreamList(), null, tracks);
|
||||
WaveformSelection selection = WaveformSelection.from(waveformPane.getSelection());
|
||||
boolean selectedTransaction = selection.transaction() != null && selection.track() != null;
|
||||
return new ViewerSettings(tracks, waveformPane.getCursorList().stream().map(ICursor::getTime).toList(),
|
||||
@@ -677,14 +686,30 @@ public class WaveformViewer implements IPreferenceChangeListener, DisposeListene
|
||||
waveformPane.setSelection(StructuredSelection.EMPTY);
|
||||
waveformPane.getStreamList().clear();
|
||||
List<TrackEntry> selectedTracks = new ArrayList<>();
|
||||
Map<ViewerSettings.Track, TrackEntry> entries = new java.util.IdentityHashMap<>();
|
||||
TrackEntry transactionTrack = null;
|
||||
for (ResolvedTrack track : resolved) {
|
||||
TrackEntry entry = waveformPane.addWaveform(track.waveform(), -1);
|
||||
entry.valueDisplay = track.settings().valueDisplay();
|
||||
entry.waveDisplay = track.settings().waveDisplay();
|
||||
if (track.settings().group()) entry.hierState = track.settings().expanded()
|
||||
? TrackEntry.HierState.OPENED : TrackEntry.HierState.CLOSED;
|
||||
entries.put(track.settings(), entry);
|
||||
if (track.settings().selected()) selectedTracks.add(entry);
|
||||
if (track.waveform() == selectedWaveform) transactionTrack = entry;
|
||||
}
|
||||
for (ViewerSettings.Track track : settings.tracks()) {
|
||||
if (track.parent() == null) continue;
|
||||
TrackEntry child = entries.get(track);
|
||||
TrackEntry parent = entries.get(settings.tracks().get(track.parent()));
|
||||
if (child != null && parent != null) {
|
||||
waveformPane.getStreamList().remove(child);
|
||||
parent.waveforms.add(child);
|
||||
}
|
||||
}
|
||||
List<TrackEntry> visible = TrackEntry.visibleTracks(waveformPane.getStreamList());
|
||||
selectedTracks.retainAll(visible);
|
||||
if (!visible.contains(transactionTrack)) transactionTrack = null;
|
||||
List<ICursor> cursors = waveformPane.getCursorList();
|
||||
if (settings.cursors().size() == cursors.size()) {
|
||||
for (int i = 0; i < cursors.size(); i++) cursors.get(i).setTime(settings.cursors().get(i));
|
||||
@@ -810,13 +835,15 @@ public class WaveformViewer implements IPreferenceChangeListener, DisposeListene
|
||||
java.util.Optional<TrackEntry> o = selection.toList().stream().filter(e -> e instanceof TrackEntry).findFirst();
|
||||
if(o.isPresent()) {
|
||||
TrackEntry trackEntry = o.get();
|
||||
if (insert) {
|
||||
int index = waveformPane.getStreamList().indexOf(trackEntry);
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, index++);
|
||||
} else {
|
||||
for (IWaveform waveform : iWaveforms)
|
||||
waveformPane.addWaveform(waveform, -1);
|
||||
List<TrackEntry> siblings = TrackEntry.siblingsOf(waveformPane.getStreamList(), trackEntry);
|
||||
if (siblings != null) {
|
||||
int index = insert ? siblings.indexOf(trackEntry) : siblings.indexOf(trackEntry) + 1;
|
||||
for (IWaveform waveform : iWaveforms) {
|
||||
TrackEntry added = waveformPane.addWaveform(waveform, -1);
|
||||
waveformPane.getStreamList().remove(added);
|
||||
siblings.add(index++, added);
|
||||
}
|
||||
waveformPane.update();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -898,6 +925,27 @@ public class WaveformViewer implements IPreferenceChangeListener, DisposeListene
|
||||
updateAll();
|
||||
}
|
||||
|
||||
public boolean canGroupSelectedTracks() {
|
||||
return waveformPane != null && TrackEntry.groupingSiblings(waveformPane.getStreamList(),
|
||||
WaveformSelection.from(getSelection()).tracks()) != null;
|
||||
}
|
||||
|
||||
public boolean canUngroupSelectedTracks() {
|
||||
return waveformPane != null && WaveformSelection.from(getSelection()).tracks().stream()
|
||||
.anyMatch(track -> track.isGroup() && TrackEntry.siblingsOf(waveformPane.getStreamList(), track) != null);
|
||||
}
|
||||
|
||||
public void groupSelectedTracks(String name) {
|
||||
if (canGroupSelectedTracks() && name != null && !name.isBlank()) waveformPane.groupSelectedTracks(name);
|
||||
}
|
||||
|
||||
public void ungroupSelectedTracks() {
|
||||
if (waveformPane == null) return;
|
||||
for (TrackEntry track : WaveformSelection.from(getSelection()).tracks()) {
|
||||
if (track.isGroup()) waveformPane.ungroupTracks(track);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selection.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user