Skip to content

Commit dc4798b

Browse files
committed
implements visual improvements
1 parent 3890a87 commit dc4798b

File tree

7 files changed

+72
-64
lines changed

7 files changed

+72
-64
lines changed

plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import com.minres.scviewer.database.ui.IWaveformZoom;
9292
import com.minres.scviewer.database.ui.IWaveformviewEventListener;
9393
import com.minres.scviewer.database.ui.TrackEntry;
94+
import com.minres.scviewer.database.ui.TrackEntry.HierState;
9495
import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar;
9596

9697
public class WaveformView implements IWaveformView {
@@ -155,11 +156,13 @@ public void mouseDown(MouseEvent e) {
155156
setSelection(new StructuredSelection(entry.getValue()), false, false);
156157
lastClickedEntry = entry.getValue();
157158
} else {
158-
StructuredSelection structuredSelection = (StructuredSelection) sel;
159-
if(structuredSelection.size()== 1 && structuredSelection.getFirstElement() instanceof TrackEntry) {
159+
@SuppressWarnings("unchecked")
160+
long c = ((IStructuredSelection)sel).toList().stream().filter(x -> x instanceof TrackEntry).count();
161+
if(c==1) {
160162
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
161-
TrackEntry selEntry = (TrackEntry) structuredSelection.getFirstElement();
162-
if(!entry.getValue().equals(selEntry)) {
163+
@SuppressWarnings("unchecked")
164+
Optional<TrackEntry> o = ((IStructuredSelection)sel).toList().stream().filter(x -> x instanceof TrackEntry).findFirst();
165+
if(!entry.getValue().equals(o.get())) {
163166
setSelection(new StructuredSelection(entry.getValue()), false, false);
164167
lastClickedEntry = entry.getValue();
165168
}
@@ -347,9 +350,7 @@ public void handleEvent(Event e) {
347350
default:
348351
break;
349352
}
350-
351353
}
352-
353354
}
354355

355356
protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener();
@@ -588,7 +589,7 @@ public void update() {
588589
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
589590
tl.setFont(styleProvider.getNameFont());
590591
for (TrackEntry streamEntry : streams) {
591-
if(streamEntry.hierState == TrackEntry.HierState.OPENED) {
592+
if(streamEntry.hierState == HierState.OPENED) {
592593
for (TrackEntry trackEntry : streamEntry.waveforms) {
593594
addPainter(even, trackEntry);
594595
trackVerticalOffset.put(tracksVerticalHeight, trackEntry);
@@ -1161,16 +1162,13 @@ protected void paintValues(GC gc, Rectangle rect) {
11611162
if (lastKey.equals(firstKey)) {
11621163
TrackEntry trackEntry = trackVerticalOffset.get(firstKey);
11631164
IWaveform w = trackEntry.waveform;
1164-
if (w.getType() == WaveformType.TRANSACTION)
1165-
subArea.height *= w.getRowCount();
1165+
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
11661166
drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected);
11671167
} else {
11681168
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
11691169
.entrySet()) {
11701170
IWaveform w = entry.getValue().waveform;
1171-
subArea.height = styleProvider.getTrackHeight();
1172-
if (w.getType() == WaveformType.TRANSACTION)
1173-
subArea.height *= w.getRowCount();
1171+
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
11741172
drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue,
11751173
entry.getValue().selected);
11761174
}
@@ -1180,10 +1178,9 @@ protected void paintValues(GC gc, Rectangle rect) {
11801178
}
11811179
}
11821180

1183-
private void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) {
1181+
protected void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) {
11841182
IWaveform w = entry.waveform;
1185-
if (w.getType() == WaveformType.TRANSACTION)
1186-
subArea.height *= w.getRowCount();
1183+
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
11871184
drawTextFormat(gc, subArea, firstKey, w.getFullName(), entry.selected, entry.hierState);
11881185
}
11891186

@@ -1199,10 +1196,10 @@ protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value
11991196
}
12001197

12011198
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
1202-
drawTextFormat(gc, subArea, yOffset, value, highlite, TrackEntry.HierState.NONE);
1199+
drawTextFormat(gc, subArea, yOffset, value, highlite, HierState.NONE);
12031200
}
12041201

1205-
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite, TrackEntry.HierState state) {
1202+
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite, HierState state) {
12061203
Point size = gc.textExtent(value);
12071204
int height = styleProvider.getTrackHeight();
12081205
if (highlite) {
@@ -1215,14 +1212,28 @@ protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String valu
12151212
gc.setForeground(namePaneHeader.getForeground());
12161213
gc.setFont(styleProvider.getNameFont());
12171214
}
1218-
if(state==TrackEntry.HierState.NONE) {
1215+
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
1216+
/* if(state==HierState.NONE) {
12191217
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
12201218
} else {
12211219
gc.setBackground(highlite?SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT):namePaneHeader.getForeground());
1222-
gc.fillPolygon(new int[]{3, yOffset+(height-10)/2, 10, yOffset+height/2, 3, yOffset+(height+10)/2});
1220+
int o = yOffset + (height-12)/2;
1221+
if(state==HierState.OPENED) {
1222+
Point tl = new Point(1,o+2);
1223+
Point tr = new Point(10,o+2);
1224+
Point br = new Point(6,o+9);
1225+
Point bl = new Point(5,o+9);
1226+
gc.fillPolygon(new int[] {tl.x, tl.y, tr.x, tr.y, br.x, br.y, bl.x, bl.y});
1227+
} else {
1228+
Point tl = new Point(2,o+1);
1229+
Point tr = new Point(9,o+5);
1230+
Point br = new Point(9,o+6);
1231+
Point bl = new Point(2,o+10);
1232+
gc.fillPolygon(new int[] {tl.x, tl.y, tr.x, tr.y, br.x, br.y, bl.x, bl.y});
1233+
}
12231234
Rectangle textArea = new Rectangle(subArea.x+12, subArea.y, subArea.width-12, subArea.height);
12241235
gc.drawText(value, textArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
1225-
}
1236+
}*/
12261237
}
12271238

12281239
public void setHighliteRelation(RelationType relationType) {

plugins/com.minres.scviewer.e4.application/Application.e4xmi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<handlers xmi:id="_TwU0IEYoEeyKK_icsY7Xjg" elementId="com.minres.scviewer.e4.application.handler.enabletxdetails" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.EnableTxDetails" command="_Fj1gQEYoEeyKK_icsY7Xjg"/>
119119
<handlers xmi:id="_htyxgHCOEeyub8CfGE1sGA" elementId="com.minres.scviewer.e4.application.handler.helpContent" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.HelpContentsHandler" command="_RdUMoHCOEeyub8CfGE1sGA"/>
120120
<handlers xmi:id="__Ozu4LcxEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.handler.add_separator" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.AddSeparatorHandler" command="_vYAOQLcxEe294PIiYLxpfA"/>
121-
<handlers xmi:id="_zpAa4LepEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.handler.set_label_text" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SetLabelTextHandler" command="_wcqasLepEe294PIiYLxpfA"/>
121+
<handlers xmi:id="_zpAa4LepEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.handler.wave_double_click" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.WaveformDoubleClickTextHandler" command="_wcqasLepEe294PIiYLxpfA"/>
122122
<bindingTables xmi:id="_95PfvnNmEeWBq8z1Dv39LA" bindingContext="_95PfuXNmEeWBq8z1Dv39LA">
123123
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.quit" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA">
124124
<tags>type:user</tags>
@@ -218,7 +218,7 @@
218218
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_Se1voBlEEeuiP60JNw0iiA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler"/>
219219
</children>
220220
<children xsi:type="menu:HandledMenuItem" xmi:id="_Wblk0LexEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.handledmenuitem.edit_text" label="Edit Text" command="_wcqasLepEe294PIiYLxpfA">
221-
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_fH08MLexEe294PIiYLxpfA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SetLabelTextHandler"/>
221+
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_fH08MLexEe294PIiYLxpfA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.WaveformDoubleClickTextHandler"/>
222222
</children>
223223
</menus>
224224
<toolbar xmi:id="_ReeeAE-DEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.toolbar.3">
@@ -319,7 +319,7 @@
319319
<parameters xmi:id="_y2BUsU-HEeyuGJbYVZjX8w" elementId="com.minres.scviewer.e4.application.command.pancommand.parameter.direction" name="direction" optional="false"/>
320320
</commands>
321321
<commands xmi:id="_RdUMoHCOEeyub8CfGE1sGA" elementId="org.eclipse.ui.help.helpContentCommand" commandName="Help Content Command" description=""/>
322-
<commands xmi:id="_wcqasLepEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.command.set_label_text" commandName="Set Label Text"/>
322+
<commands xmi:id="_wcqasLepEe294PIiYLxpfA" elementId="com.minres.scviewer.e4.application.command.wave_double_click" commandName="Waveform Double Click"/>
323323
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
324324
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
325325
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>

plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class AppModelId {
4141
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_PANCOMMAND = "com.minres.scviewer.e4.application.command.pancommand";
4242
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SELECTALLCOMMAND = "com.minres.scviewer.e4.application.command.selectallCommand";
4343
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SETRELATIONTYPE = "com.minres.scviewer.e4.application.command.setrelationtype";
44-
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SET_LABEL_TEXT = "com.minres.scviewer.e4.application.command.set_label_text";
44+
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_WAVE_DOUBLE_CLICK = "com.minres.scviewer.e4.application.command.wave_double_click";
4545
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SET_THEM = "com.minres.scviewer.e4.application.command.set_them";
4646
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_UPDATE = "com.minres.scviewer.e4.application.command.update";
4747
public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_ZOOMCOMMAND = "com.minres.scviewer.e4.application.command.zoomcommand";

plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddSeparatorHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
package com.minres.scviewer.e4.application.handlers;
1313

14+
import java.util.Optional;
15+
1416
import javax.inject.Named;
1517

1618
import org.eclipse.e4.core.di.annotations.CanExecute;
@@ -34,12 +36,11 @@ public Boolean canExecute(EPartService partService){
3436
if(part!=null && part.getObject() instanceof WaveformViewer){
3537
Object sel = ((WaveformViewer)part.getObject()).getSelection();
3638
if( sel instanceof IStructuredSelection) {
37-
if(((IStructuredSelection)sel).isEmpty()) return false;
38-
IStructuredSelection isel = (IStructuredSelection) sel;
39-
if(isel.size()==1)
40-
return isel.getFirstElement() instanceof TrackEntry;
41-
else if(isel.size()==2) {
42-
return isel.toArray()[1] instanceof TrackEntry;
39+
if( sel instanceof IStructuredSelection) {
40+
if(((IStructuredSelection)sel).isEmpty()) return false;
41+
@SuppressWarnings("unchecked")
42+
Optional<TrackEntry> o= ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst();
43+
return o.isPresent();
4344
}
4445
}
4546
}

plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
package com.minres.scviewer.e4.application.handlers;
1313

14+
import java.util.Optional;
15+
1416
import org.eclipse.e4.core.di.annotations.CanExecute;
1517
import org.eclipse.e4.core.di.annotations.Execute;
1618
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
@@ -25,13 +27,11 @@ public class DeleteWaveformHandler {
2527
@SuppressWarnings("unchecked")
2628
@CanExecute
2729
public Boolean canExecute(ESelectionService selectionService){
28-
Object o = selectionService.getSelection();
29-
if(o instanceof IStructuredSelection) {
30-
IStructuredSelection sel = (IStructuredSelection) o;
31-
if(sel.size()>0)
32-
return sel.toList().stream().allMatch(e-> e instanceof TrackEntry);
33-
else
34-
return false;
30+
Object sel = selectionService.getSelection();
31+
if(sel instanceof IStructuredSelection) {
32+
if(((IStructuredSelection)sel).isEmpty()) return false;
33+
Optional<TrackEntry> o= ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst();
34+
return o.isPresent();
3535
} else
3636
return false;
3737
}
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
package com.minres.scviewer.e4.application.handlers;
1313

14+
import java.util.Optional;
15+
1416
import org.eclipse.e4.core.di.annotations.CanExecute;
1517
import org.eclipse.e4.core.di.annotations.Evaluate;
1618
import org.eclipse.e4.core.di.annotations.Execute;
@@ -22,20 +24,22 @@
2224

2325
import com.minres.scviewer.database.EmptyWaveform;
2426
import com.minres.scviewer.database.ui.TrackEntry;
27+
import com.minres.scviewer.database.ui.TrackEntry.HierState;
2528
import com.minres.scviewer.e4.application.parts.TextInputDialog;
2629
import com.minres.scviewer.e4.application.parts.WaveformViewer;
2730

28-
public class SetLabelTextHandler {
31+
public class WaveformDoubleClickTextHandler {
2932

3033
@Execute
3134
public void execute(Shell shell, EPartService partService) {
3235
MPart part = partService.getActivePart();
3336
if(part!=null && part.getObject() instanceof WaveformViewer){
3437
Object sel = ((WaveformViewer)part.getObject()).getSelection();
3538
if( sel instanceof IStructuredSelection) {
36-
Object o= ((IStructuredSelection)sel).getFirstElement();
37-
if(o instanceof TrackEntry) {
38-
TrackEntry te = (TrackEntry)o;
39+
@SuppressWarnings("unchecked")
40+
Optional<TrackEntry> o = ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst();
41+
if(o.isPresent()) {
42+
TrackEntry te = o.get();
3943
if(te.waveform instanceof EmptyWaveform) {
4044
EmptyWaveform waveform= (EmptyWaveform)te.waveform;
4145
TextInputDialog dialog = new TextInputDialog(shell);
@@ -45,6 +49,10 @@ public void execute(Shell shell, EPartService partService) {
4549
if (dialog.open() == Window.OK) {
4650
waveform.setName(dialog.getText());
4751
}
52+
} else if(te.hierState==HierState.CLOSED) {
53+
te.hierState=HierState.OPENED;
54+
} else if(te.hierState==HierState.OPENED) {
55+
te.hierState=HierState.CLOSED;
4856
}
4957
}
5058
}
@@ -59,10 +67,11 @@ public Boolean canExecute(MPart activePart){
5967
Object sel = ((WaveformViewer)activePart.getObject()).getSelection();
6068
if( sel instanceof IStructuredSelection) {
6169
if(((IStructuredSelection)sel).isEmpty()) return false;
62-
Object o= ((IStructuredSelection)sel).getFirstElement();
63-
if(o instanceof TrackEntry) {
64-
TrackEntry te = (TrackEntry)o;
65-
return te.waveform instanceof EmptyWaveform;
70+
@SuppressWarnings("unchecked")
71+
Optional<TrackEntry> o = ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst();
72+
if(o.isPresent()) {
73+
TrackEntry te = o.get();
74+
return te.waveform instanceof EmptyWaveform || te.hierState!=HierState.NONE;
6675
}
6776
}
6877
}

plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public void partActivated(MPart part) {
418418
waveformPane.addEventListner(new IWaveformviewEventListener() {
419419
@Override
420420
public void onTrackEntryDoubleClickEvent(TrackEntry trackEntry) {
421-
ParameterizedCommand command = commandService.createCommand(AppModelId.COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SET_LABEL_TEXT);
421+
ParameterizedCommand command = commandService.createCommand(AppModelId.COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_WAVE_DOUBLE_CLICK);
422422
handlerService.executeHandler(command);
423423
}
424424
});
@@ -1000,9 +1000,10 @@ public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) {
10001000
for (IWaveform waveform : iWaveforms)
10011001
waveformPane.addWaveform(waveform, -1);
10021002
} else {
1003-
Object first = selection.getFirstElement();
1004-
if(first instanceof ITx) {
1005-
TrackEntry trackEntry = waveformPane.getEntryFor((ITx) first);
1003+
@SuppressWarnings("unchecked")
1004+
java.util.Optional<TrackEntry> o = selection.toList().stream().filter(e -> e instanceof TrackEntry).findFirst();
1005+
if(o.isPresent()) {
1006+
TrackEntry trackEntry = o.get();
10061007
if (insert) {
10071008
int index = waveformPane.getStreamList().indexOf(trackEntry);
10081009
for (IWaveform waveform : iWaveforms)
@@ -1011,18 +1012,8 @@ public void addStreamsToList(IWaveform[] iWaveforms, boolean insert) {
10111012
for (IWaveform waveform : iWaveforms)
10121013
waveformPane.addWaveform(waveform, -1);
10131014
}
1014-
} else if(first instanceof TrackEntry) {
1015-
TrackEntry trackEntry = (TrackEntry) first;
1016-
if (insert) {
1017-
int index = waveformPane.getStreamList().indexOf(trackEntry);
1018-
for (IWaveform waveform : iWaveforms)
1019-
waveformPane.addWaveform(waveform, index++);
1020-
} else {
1021-
for (IWaveform waveform : iWaveforms)
1022-
waveformPane.addWaveform(waveform, -1);
1023-
}
1024-
}
10251015

1016+
}
10261017
}
10271018
showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent());
10281019
setFocus();
@@ -1033,10 +1024,6 @@ public void removeSelectedStreamsFromList() {
10331024
showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent());
10341025
}
10351026

1036-
public void removeSelectedStreamFromList() {
1037-
waveformPane.deleteSelectedTracks();
1038-
showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent());
1039-
}
10401027
/**
10411028
* Move selected.
10421029
*

0 commit comments

Comments
 (0)