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 2ba50de..3bcf249 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 @@ -91,6 +91,7 @@ import com.minres.scviewer.database.ui.IWaveformView; import com.minres.scviewer.database.ui.IWaveformZoom; import com.minres.scviewer.database.ui.IWaveformviewEventListener; import com.minres.scviewer.database.ui.TrackEntry; +import com.minres.scviewer.database.ui.TrackEntry.HierState; import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar; public class WaveformView implements IWaveformView { @@ -155,11 +156,13 @@ public class WaveformView implements IWaveformView { setSelection(new StructuredSelection(entry.getValue()), false, false); lastClickedEntry = entry.getValue(); } else { - StructuredSelection structuredSelection = (StructuredSelection) sel; - if(structuredSelection.size()== 1 && structuredSelection.getFirstElement() instanceof TrackEntry) { + @SuppressWarnings("unchecked") + long c = ((IStructuredSelection)sel).toList().stream().filter(x -> x instanceof TrackEntry).count(); + if(c==1) { Entry entry = trackVerticalOffset.floorEntry(e.y); - TrackEntry selEntry = (TrackEntry) structuredSelection.getFirstElement(); - if(!entry.getValue().equals(selEntry)) { + @SuppressWarnings("unchecked") + Optional o = ((IStructuredSelection)sel).toList().stream().filter(x -> x instanceof TrackEntry).findFirst(); + if(!entry.getValue().equals(o.get())) { setSelection(new StructuredSelection(entry.getValue()), false, false); lastClickedEntry = entry.getValue(); } @@ -347,9 +350,7 @@ public class WaveformView implements IWaveformView { default: break; } - } - } protected WaveformMouseListener waveformMouseListener = new WaveformMouseListener(); @@ -588,7 +589,7 @@ public class WaveformView implements IWaveformView { TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); tl.setFont(styleProvider.getNameFont()); for (TrackEntry streamEntry : streams) { - if(streamEntry.hierState == TrackEntry.HierState.OPENED) { + if(streamEntry.hierState == HierState.OPENED) { for (TrackEntry trackEntry : streamEntry.waveforms) { addPainter(even, trackEntry); trackVerticalOffset.put(tracksVerticalHeight, trackEntry); @@ -1161,16 +1162,13 @@ public class WaveformView implements IWaveformView { if (lastKey.equals(firstKey)) { TrackEntry trackEntry = trackVerticalOffset.get(firstKey); IWaveform w = trackEntry.waveform; - if (w.getType() == WaveformType.TRANSACTION) - subArea.height *= w.getRowCount(); + subArea.height = w.getRowCount() * styleProvider.getTrackHeight(); drawValue(gc, subArea, firstKey, trackEntry.currentValue, trackEntry.selected); } else { for (Entry entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) .entrySet()) { IWaveform w = entry.getValue().waveform; - subArea.height = styleProvider.getTrackHeight(); - if (w.getType() == WaveformType.TRANSACTION) - subArea.height *= w.getRowCount(); + subArea.height = w.getRowCount() * styleProvider.getTrackHeight(); drawValue(gc, subArea, entry.getKey(), entry.getValue().currentValue, entry.getValue().selected); } @@ -1180,10 +1178,9 @@ public class WaveformView implements IWaveformView { } } - private void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) { + protected void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) { IWaveform w = entry.waveform; - if (w.getType() == WaveformType.TRANSACTION) - subArea.height *= w.getRowCount(); + subArea.height = w.getRowCount() * styleProvider.getTrackHeight(); drawTextFormat(gc, subArea, firstKey, w.getFullName(), entry.selected, entry.hierState); } @@ -1199,10 +1196,10 @@ public class WaveformView implements IWaveformView { } protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) { - drawTextFormat(gc, subArea, yOffset, value, highlite, TrackEntry.HierState.NONE); + drawTextFormat(gc, subArea, yOffset, value, highlite, HierState.NONE); } - protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite, TrackEntry.HierState state) { + protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite, HierState state) { Point size = gc.textExtent(value); int height = styleProvider.getTrackHeight(); if (highlite) { @@ -1215,14 +1212,28 @@ public class WaveformView implements IWaveformView { gc.setForeground(namePaneHeader.getForeground()); gc.setFont(styleProvider.getNameFont()); } - if(state==TrackEntry.HierState.NONE) { + gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true); +/* if(state==HierState.NONE) { gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true); } else { gc.setBackground(highlite?SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT):namePaneHeader.getForeground()); - gc.fillPolygon(new int[]{3, yOffset+(height-10)/2, 10, yOffset+height/2, 3, yOffset+(height+10)/2}); + int o = yOffset + (height-12)/2; + if(state==HierState.OPENED) { + Point tl = new Point(1,o+2); + Point tr = new Point(10,o+2); + Point br = new Point(6,o+9); + Point bl = new Point(5,o+9); + gc.fillPolygon(new int[] {tl.x, tl.y, tr.x, tr.y, br.x, br.y, bl.x, bl.y}); + } else { + Point tl = new Point(2,o+1); + Point tr = new Point(9,o+5); + Point br = new Point(9,o+6); + Point bl = new Point(2,o+10); + gc.fillPolygon(new int[] {tl.x, tl.y, tr.x, tr.y, br.x, br.y, bl.x, bl.y}); + } Rectangle textArea = new Rectangle(subArea.x+12, subArea.y, subArea.width-12, subArea.height); gc.drawText(value, textArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true); - } + }*/ } public void setHighliteRelation(RelationType relationType) { diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi index 107c4ec..e2b3bd8 100644 --- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi +++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi @@ -118,7 +118,7 @@ - + type:user @@ -218,7 +218,7 @@ - + @@ -319,7 +319,7 @@ - + diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java index b8673b6..066013d 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/AppModelId.java @@ -41,7 +41,7 @@ public class AppModelId { public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_PANCOMMAND = "com.minres.scviewer.e4.application.command.pancommand"; public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SELECTALLCOMMAND = "com.minres.scviewer.e4.application.command.selectallCommand"; public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SETRELATIONTYPE = "com.minres.scviewer.e4.application.command.setrelationtype"; - public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SET_LABEL_TEXT = "com.minres.scviewer.e4.application.command.set_label_text"; + public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_WAVE_DOUBLE_CLICK = "com.minres.scviewer.e4.application.command.wave_double_click"; public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SET_THEM = "com.minres.scviewer.e4.application.command.set_them"; public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_UPDATE = "com.minres.scviewer.e4.application.command.update"; public static final String COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_ZOOMCOMMAND = "com.minres.scviewer.e4.application.command.zoomcommand"; diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddSeparatorHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddSeparatorHandler.java index 91686c5..aa31343 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddSeparatorHandler.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddSeparatorHandler.java @@ -11,6 +11,8 @@ package com.minres.scviewer.e4.application.handlers; +import java.util.Optional; + import javax.inject.Named; import org.eclipse.e4.core.di.annotations.CanExecute; @@ -34,12 +36,11 @@ public class AddSeparatorHandler { if(part!=null && part.getObject() instanceof WaveformViewer){ Object sel = ((WaveformViewer)part.getObject()).getSelection(); if( sel instanceof IStructuredSelection) { - if(((IStructuredSelection)sel).isEmpty()) return false; - IStructuredSelection isel = (IStructuredSelection) sel; - if(isel.size()==1) - return isel.getFirstElement() instanceof TrackEntry; - else if(isel.size()==2) { - return isel.toArray()[1] instanceof TrackEntry; + if( sel instanceof IStructuredSelection) { + if(((IStructuredSelection)sel).isEmpty()) return false; + @SuppressWarnings("unchecked") + Optional o= ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst(); + return o.isPresent(); } } } diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java index b0228b7..2603b38 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/DeleteWaveformHandler.java @@ -11,6 +11,8 @@ package com.minres.scviewer.e4.application.handlers; +import java.util.Optional; + 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; @@ -25,13 +27,11 @@ public class DeleteWaveformHandler { @SuppressWarnings("unchecked") @CanExecute public Boolean canExecute(ESelectionService selectionService){ - Object o = selectionService.getSelection(); - if(o instanceof IStructuredSelection) { - IStructuredSelection sel = (IStructuredSelection) o; - if(sel.size()>0) - return sel.toList().stream().allMatch(e-> e instanceof TrackEntry); - else - return false; + Object sel = selectionService.getSelection(); + if(sel instanceof IStructuredSelection) { + if(((IStructuredSelection)sel).isEmpty()) return false; + Optional o= ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst(); + return o.isPresent(); } else return false; } diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetLabelTextHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/WaveformDoubleClickTextHandler.java similarity index 73% rename from plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetLabelTextHandler.java rename to plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/WaveformDoubleClickTextHandler.java index 2047555..7aaa71a 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SetLabelTextHandler.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/WaveformDoubleClickTextHandler.java @@ -11,6 +11,8 @@ package com.minres.scviewer.e4.application.handlers; +import java.util.Optional; + import org.eclipse.e4.core.di.annotations.CanExecute; import org.eclipse.e4.core.di.annotations.Evaluate; import org.eclipse.e4.core.di.annotations.Execute; @@ -22,10 +24,11 @@ import org.eclipse.swt.widgets.Shell; import com.minres.scviewer.database.EmptyWaveform; import com.minres.scviewer.database.ui.TrackEntry; +import com.minres.scviewer.database.ui.TrackEntry.HierState; import com.minres.scviewer.e4.application.parts.TextInputDialog; import com.minres.scviewer.e4.application.parts.WaveformViewer; -public class SetLabelTextHandler { +public class WaveformDoubleClickTextHandler { @Execute public void execute(Shell shell, EPartService partService) { @@ -33,9 +36,10 @@ public class SetLabelTextHandler { if(part!=null && part.getObject() instanceof WaveformViewer){ Object sel = ((WaveformViewer)part.getObject()).getSelection(); if( sel instanceof IStructuredSelection) { - Object o= ((IStructuredSelection)sel).getFirstElement(); - if(o instanceof TrackEntry) { - TrackEntry te = (TrackEntry)o; + @SuppressWarnings("unchecked") + Optional o = ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst(); + if(o.isPresent()) { + TrackEntry te = o.get(); if(te.waveform instanceof EmptyWaveform) { EmptyWaveform waveform= (EmptyWaveform)te.waveform; TextInputDialog dialog = new TextInputDialog(shell); @@ -45,6 +49,10 @@ public class SetLabelTextHandler { if (dialog.open() == Window.OK) { waveform.setName(dialog.getText()); } + } else if(te.hierState==HierState.CLOSED) { + te.hierState=HierState.OPENED; + } else if(te.hierState==HierState.OPENED) { + te.hierState=HierState.CLOSED; } } } @@ -59,10 +67,11 @@ public class SetLabelTextHandler { Object sel = ((WaveformViewer)activePart.getObject()).getSelection(); if( sel instanceof IStructuredSelection) { if(((IStructuredSelection)sel).isEmpty()) return false; - Object o= ((IStructuredSelection)sel).getFirstElement(); - if(o instanceof TrackEntry) { - TrackEntry te = (TrackEntry)o; - return te.waveform instanceof EmptyWaveform; + @SuppressWarnings("unchecked") + Optional o = ((IStructuredSelection)sel).toList().stream().filter(e -> e instanceof TrackEntry).findFirst(); + if(o.isPresent()) { + TrackEntry te = o.get(); + return te.waveform instanceof EmptyWaveform || te.hierState!=HierState.NONE; } } } 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 642f4d8..5d6ba8a 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 @@ -418,7 +418,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.addEventListner(new IWaveformviewEventListener() { @Override public void onTrackEntryDoubleClickEvent(TrackEntry trackEntry) { - ParameterizedCommand command = commandService.createCommand(AppModelId.COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_SET_LABEL_TEXT); + ParameterizedCommand command = commandService.createCommand(AppModelId.COMMAND_COM_MINRES_SCVIEWER_E4_APPLICATION_COMMAND_WAVE_DOUBLE_CLICK); handlerService.executeHandler(command); } }); @@ -1000,9 +1000,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis for (IWaveform waveform : iWaveforms) waveformPane.addWaveform(waveform, -1); } else { - Object first = selection.getFirstElement(); - if(first instanceof ITx) { - TrackEntry trackEntry = waveformPane.getEntryFor((ITx) first); + @SuppressWarnings("unchecked") + java.util.Optional 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) @@ -1011,18 +1012,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis for (IWaveform waveform : iWaveforms) waveformPane.addWaveform(waveform, -1); } - } else if(first instanceof TrackEntry) { - TrackEntry trackEntry = (TrackEntry) first; - 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); - } - } + } } showTxDetails(waveformPane.getStreamList().stream().filter(t -> t.waveform.getType() == WaveformType.TRANSACTION).findFirst().isPresent()); setFocus(); @@ -1033,10 +1024,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis 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. *