rename BLANK to EMPY, enhances separator render, fixes menu selection

This commit is contained in:
Eyck Jentzsch 2023-03-01 09:21:11 +01:00
parent 9be9671d3a
commit f64a1baf02
11 changed files with 149 additions and 66 deletions

View File

@ -16,5 +16,5 @@ public enum WaveformColors {
TX_BG, TX_BG_HIGHLITE, TX_BORDER, TX_BG, TX_BG_HIGHLITE, TX_BORDER,
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNAL_CHANGE, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN, SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNAL_CHANGE, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN,
CURSOR, CURSOR_DRAG, CURSOR_TEXT, CURSOR, CURSOR_DRAG, CURSOR_TEXT,
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE, BLANK MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE, SEPARATOR
} }

View File

@ -50,7 +50,7 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider {
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA); colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255); colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
colors[WaveformColors.BLANK.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_RED); colors[WaveformColors.SEPARATOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
} }
/** /**
* needs redraw() afterwards * needs redraw() afterwards

View File

@ -1,45 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.ui.swt.internal;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.WaveformColors;
public class BlankPainter extends TrackPainter {
/**
*
*/
private final WaveformCanvas waveCanvas;
public BlankPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
super(trackEntry, even);
this.waveCanvas = txDisplay;
}
public void paintArea(Projection proj, Rectangle area) {
if (trackEntry.selected)
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE));
else
proj.setBackground(this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD));
proj.setFillRule(SWT.FILL_EVEN_ODD);
proj.fillRectangle(area);
int trackHeight=trackEntry.height;
int txBase=trackHeight*2/5;
int txHeight=trackHeight/5;
Rectangle bb = new Rectangle(area.x, area.y+txBase, area.width, txHeight);
proj.setBackground(this.waveCanvas.styleProvider.getColor(WaveformColors.BLANK));
proj.fillRectangle(bb);
}
}

View File

@ -0,0 +1,85 @@
/*******************************************************************************
* Copyright (c) 2015-2021 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.ui.swt.internal;
import javax.swing.JPanel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.WaveformColors;
public class EmptyPainter extends TrackPainter {
/**
*
*/
private final WaveformCanvas waveCanvas;
private static final JPanel DUMMY_PANEL = new JPanel();
public EmptyPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
super(trackEntry, even);
this.waveCanvas = txDisplay;
}
public void paintArea(Projection proj, Rectangle area) {
Color bgColor = trackEntry.selected?this.waveCanvas.styleProvider.getColor(WaveformColors.TRACK_BG_HIGHLITE):this.waveCanvas.styleProvider.getColor(even ? WaveformColors.TRACK_BG_EVEN : WaveformColors.TRACK_BG_ODD);
GC gc = proj.getGC();
proj.setBackground(bgColor);
proj.setFillRule(SWT.FILL_EVEN_ODD);
proj.fillRectangle(area);
Color drawColor = this.waveCanvas.styleProvider.getColor(WaveformColors.SEPARATOR);
int trackHeight=trackEntry.height;
int txBase=trackHeight*2/5;
int txHeight=trackHeight/5;
proj.setBackground(drawColor);
proj.fillRectangle(new Rectangle(area.x, area.y+txBase, area.width, txHeight));
String label = trackEntry.waveform.getName();
if(label.length()>0) {
Color textColor=waveCanvas.styleProvider.getColor(WaveformColors.SIGNAL_TEXT);
FontData fd = gc.getFont().getFontData()[0];
int height = gc.getDevice().getDPI().y * fd.getHeight() / 72;
java.awt.Font tmpAwtFont = new java.awt.Font(fd.getName(), fd.getStyle(), height);
int width = DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(label);
int xBegin = (area.width-width)/2-5;
xBegin = xBegin<0?0:xBegin;
int xEnd = (area.width+width)/2+5;
xEnd = xEnd>area.width?area.width:xEnd;
int yOffsetT = this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
int yOffsetM = this.waveCanvas.styleProvider.getTrackHeight() / 2 + area.y;
int yOffsetB = 4 * this.waveCanvas.styleProvider.getTrackHeight() / 5 + area.y;
int[] points = {
xBegin, yOffsetM,
xBegin + 1, yOffsetT,
xEnd - 1, yOffsetT,
xEnd, yOffsetM,
xEnd - 1, yOffsetB,
xBegin + 1, yOffsetB
};
gc.setBackground(bgColor);
gc.fillPolygon(points);
gc.setForeground(drawColor);
gc.drawPolygon(points);
Rectangle old = gc.getClipping();
gc.setForeground(textColor);
gc.setClipping(xBegin + 3, yOffsetT, xEnd - xBegin - 5, yOffsetB - yOffsetT);
gc.drawText(label, xBegin + 3, yOffsetM - height / 2 - 1);
gc.setClipping(old);
}
}
}

View File

@ -149,6 +149,24 @@ public class WaveformView implements IWaveformView {
if (entry != null) if (entry != null)
entry.getValue().selected = true; entry.getValue().selected = true;
} else if (e.button == 3) { } else if (e.button == 3) {
ISelection sel = getSelection();
if(sel instanceof StructuredSelection) {
if(((StructuredSelection)sel).isEmpty()) {
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
setSelection(new StructuredSelection(entry.getValue()), false, false);
lastClickedEntry = entry.getValue();
} else {
StructuredSelection structuredSelection = (StructuredSelection) sel;
if(structuredSelection.size()== 1 && structuredSelection.getFirstElement() instanceof TrackEntry) {
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
TrackEntry selEntry = (TrackEntry) structuredSelection.getFirstElement();
if(!entry.getValue().equals(selEntry)) {
setSelection(new StructuredSelection(entry.getValue()), false, false);
lastClickedEntry = entry.getValue();
}
}
}
}
Menu topMenu = top.getMenu(); Menu topMenu = top.getMenu();
if (topMenu != null) if (topMenu != null)
topMenu.setVisible(true); topMenu.setVisible(true);
@ -182,6 +200,7 @@ public class WaveformView implements IWaveformView {
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y); Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
if(entry != null) if(entry != null)
setSelection(new StructuredSelection(entry.getValue()), false, false); setSelection(new StructuredSelection(entry.getValue()), false, false);
lastClickedEntry = entry.getValue();
for (IWaveformviewEventListener listner : eventListener) { for (IWaveformviewEventListener listner : eventListener) {
listner.onTrackEntryDoubleClickEvent(entry.getValue()); listner.onTrackEntryDoubleClickEvent(entry.getValue());
} }
@ -613,9 +632,9 @@ public class WaveformView implements IWaveformView {
} else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) { } else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) {
streamEntry.currentValue = "---"; streamEntry.currentValue = "---";
waveformCanvas.addWaveformPainter(new SignalPainter(waveformCanvas, even, streamEntry), false); waveformCanvas.addWaveformPainter(new SignalPainter(waveformCanvas, even, streamEntry), false);
} else if (streamEntry.waveform.getType() == WaveformType.BLANK) { } else if (streamEntry.waveform.getType() == WaveformType.EMPTY) {
streamEntry.currentValue = ""; streamEntry.currentValue = "";
waveformCanvas.addWaveformPainter(new BlankPainter(waveformCanvas, even, streamEntry), false); waveformCanvas.addWaveformPainter(new EmptyPainter(waveformCanvas, even, streamEntry), false);
} }
} }

View File

@ -18,6 +18,15 @@ import java.util.List;
public class EmptyWaveform implements IWaveform { public class EmptyWaveform implements IWaveform {
private String label = ""; private String label = "";
public EmptyWaveform() {
}
public EmptyWaveform(String label) {
this.label = label;
}
@Override @Override
public void addPropertyChangeListener(PropertyChangeListener l) { public void addPropertyChangeListener(PropertyChangeListener l) {
} }
@ -96,12 +105,12 @@ public class EmptyWaveform implements IWaveform {
@Override @Override
public WaveformType getType() { public WaveformType getType() {
return WaveformType.BLANK; return WaveformType.EMPTY;
} }
@Override @Override
public String getKind() { public String getKind() {
return "BLANK"; return "separator";
} }
@Override @Override

View File

@ -22,5 +22,5 @@ public enum WaveformType {
/** The filter. */ /** The filter. */
FILTER, FILTER,
/** The blank line. */ /** The blank line. */
BLANK EMPTY
} }

View File

@ -66,7 +66,7 @@
<children xsi:type="menu:ToolBar" xmi:id="_95QGzHNmEeWBq8z1Dv39LA" elementId="toolbar:org.eclipse.ui.main.toolbar"> <children xsi:type="menu:ToolBar" xmi:id="_95QGzHNmEeWBq8z1Dv39LA" elementId="toolbar:org.eclipse.ui.main.toolbar">
<children xsi:type="menu:HandledToolItem" xmi:id="_ZSajwBkZEeudD5MqrWoETQ" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" tooltip="Open new database" command="_95PfwHNmEeWBq8z1Dv39LA"/> <children xsi:type="menu:HandledToolItem" xmi:id="_ZSajwBkZEeudD5MqrWoETQ" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" tooltip="Open new database" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_95QGzXNmEeWBq8z1Dv39LA" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" tooltip="Re-load database" command="_srACsBkREeudD5MqrWoETQ"/> <children xsi:type="menu:HandledToolItem" xmi:id="_95QGzXNmEeWBq8z1Dv39LA" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" tooltip="Re-load database" command="_srACsBkREeudD5MqrWoETQ"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_o9UBUJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.handledtoolitem.loadsettings" label="Load settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg"> <children xsi:type="menu:HandledToolItem" xmi:id="_o9UBUJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.handledtoolitem.loadsettings" label="Load settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" tooltip="Load settings" command="_7-AIMJebEeW09eyIbHsdvg">
<parameters xmi:id="_tQZAEJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.32" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/> <parameters xmi:id="_tQZAEJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.32" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
</children> </children>
<children xsi:type="menu:HandledToolItem" xmi:id="_95QGznNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handledtoolitem.savesettings" toBeRendered="false" visible="false" label="Save settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/save_edit.png" command="_7-AIMJebEeW09eyIbHsdvg"> <children xsi:type="menu:HandledToolItem" xmi:id="_95QGznNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.handledtoolitem.savesettings" toBeRendered="false" visible="false" label="Save settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/save_edit.png" command="_7-AIMJebEeW09eyIbHsdvg">

View File

@ -89,7 +89,7 @@ public class Messages extends NLS {
public static String marker_text; public static String marker_text;
public static String rel_arrow; public static String rel_arrow;
public static String rel_arrow_highlite; public static String rel_arrow_highlite;
public static String blank; public static String separator;
public static String HelpBrowser_0; public static String HelpBrowser_0;
public static String HelpBrowser_1; public static String HelpBrowser_1;
public static String HelpBrowser_2; public static String HelpBrowser_2;

View File

@ -83,7 +83,7 @@ marker=Marker
marker_text=Marker TExt marker_text=Marker TExt
rel_arrow=Relation arrow rel_arrow=Relation arrow
rel_arrow_highlite=highlighted Relation arrorw rel_arrow_highlite=highlighted Relation arrorw
blank=separator separator=separator
UpdateHandler_URI=http://https://minres.github.io/SCViewer/repository UpdateHandler_URI=http://https://minres.github.io/SCViewer/repository
UpdateHandler_10=Information UpdateHandler_10=Information
UpdateHandler_11=Error UpdateHandler_11=Error

View File

@ -84,6 +84,7 @@ import org.eclipse.wb.swt.SWTResourceManager;
import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.BackingStoreException;
import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.EmptyWaveform;
import com.minres.scviewer.database.IHierNode; import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
@ -132,6 +133,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
/** The Constant SHOWN_WAVEFORM. */ /** The Constant SHOWN_WAVEFORM. */
protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; //$NON-NLS-1$ protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; //$NON-NLS-1$
protected static final String WAVEFORM_TYPE = ".WAVEFORM_TYPE"; //$NON-NLS-1$
protected static final String VALUE_DISPLAY = ".VALUE_DISPLAY"; //$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$ protected static final String WAVE_DISPLAY = ".WAVE_DISPLAY"; //$NON-NLS-1$
@ -749,9 +752,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
Integer index = 0; Integer index = 0;
for (TrackEntry trackEntry : waveformPane.getStreamList()) { for (TrackEntry trackEntry : waveformPane.getStreamList()) {
persistingState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName()); persistingState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName());
persistingState.put(SHOWN_WAVEFORM + index + WAVEFORM_TYPE, trackEntry.waveform.getType().toString());
persistingState.put(SHOWN_WAVEFORM + index + WAVEFORM_SELECTED, String.valueOf(trackEntry.selected).toUpperCase());
if (trackEntry.waveform.getType()!=WaveformType.EMPTY) {
persistingState.put(SHOWN_WAVEFORM + index + VALUE_DISPLAY, trackEntry.valueDisplay.toString()); persistingState.put(SHOWN_WAVEFORM + index + VALUE_DISPLAY, trackEntry.valueDisplay.toString());
persistingState.put(SHOWN_WAVEFORM + index + WAVE_DISPLAY, trackEntry.waveDisplay.toString()); persistingState.put(SHOWN_WAVEFORM + index + WAVE_DISPLAY, trackEntry.waveDisplay.toString());
persistingState.put(SHOWN_WAVEFORM + index + WAVEFORM_SELECTED, String.valueOf(trackEntry.selected).toUpperCase()); }
index++; index++;
} }
List<ICursor> cursors = waveformPane.getCursorList(); List<ICursor> cursors = waveformPane.getCursorList();
@ -807,6 +813,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
List<TrackEntry> trackEntries = new LinkedList<>(); List<TrackEntry> trackEntries = new LinkedList<>();
List<TrackEntry> selectedTrackEntries = new LinkedList<>(); List<TrackEntry> selectedTrackEntries = new LinkedList<>();
for (int i = 0; i < waves; i++) { for (int i = 0; i < waves; i++) {
String wtString = state.get(SHOWN_WAVEFORM + i + WAVEFORM_TYPE);
if(wtString!=null && WaveformType.valueOf(wtString)==WaveformType.EMPTY) {
TrackEntry trackEntry = waveformPane.addWaveform(new EmptyWaveform(state.get(SHOWN_WAVEFORM + i)), -1);
//check if t is selected
trackEntries.add(trackEntry);
if(Boolean.parseBoolean(state.get(SHOWN_WAVEFORM + i + WAVEFORM_SELECTED)))
selectedTrackEntries.add(trackEntry);
} else {
IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i)); IWaveform waveform = database.getStreamByName(state.get(SHOWN_WAVEFORM + i));
if (waveform != null) { if (waveform != null) {
TrackEntry trackEntry = waveformPane.addWaveform(waveform, -1); TrackEntry trackEntry = waveformPane.addWaveform(waveform, -1);
@ -822,6 +836,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
trackEntry.waveDisplay=WaveDisplay.valueOf(s); trackEntry.waveDisplay=WaveDisplay.valueOf(s);
} }
} }
}
Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$ Integer cursorLength = state.containsKey(SHOWN_CURSOR+"S")?Integer.parseInt(state.get(SHOWN_CURSOR + "S")):0; //$NON-NLS-1$ //$NON-NLS-2$
List<ICursor> cursors = waveformPane.getCursorList(); List<ICursor> cursors = waveformPane.getCursorList();
if (cursorLength == cursors.size()) { if (cursorLength == cursors.size()) {