From 52232bb0db7e0450db9d48d7e18deffe4ffe5998 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 28 Feb 2023 07:50:10 +0100 Subject: [PATCH] adds blank entry for waveform viewer --- .../scviewer/database/fst/FstLibrary.java | 1 - .../scviewer/database/ftr/FtrDbLoader.java | 1 - .../scviewer/database/text/TextDbLoader.java | 1 - .../scviewer/database/ui/TrackEntryGroup.java | 21 ++++ .../scviewer/database/ui/WaveformColors.java | 2 +- .../ui/swt/DefaultWaveformStyleProvider.java | 1 + .../ui/swt/internal/BlankPainter.java | 45 ++++++++ .../ui/swt/internal/WaveformView.java | 58 +++++++--- .../scviewer/database/vcd/VCDDbLoader.java | 1 - .../scviewer/database/BlankWaveform.java | 104 ++++++++++++++++++ .../scviewer/database/WaveformType.java | 4 +- .../Application.e4xmi | 11 ++ .../scviewer/e4/application/Messages.java | 9 +- .../handlers/AddBlankWaveformHandler.java | 54 +++++++++ .../handlers/MoveWaveformHandler.java | 17 +-- .../e4/application/messages.properties | 19 ++-- .../parts/WaveformStyleProvider.java | 27 +---- .../preferences/DefaultValuesInitializer.java | 40 +------ .../preferences/PreferenceConstants.java | 54 --------- .../preferences/WaveformPreferencesPage.java | 3 +- 20 files changed, 313 insertions(+), 160 deletions(-) create mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/TrackEntryGroup.java create mode 100644 plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/BlankPainter.java create mode 100644 plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/BlankWaveform.java create mode 100644 plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddBlankWaveformHandler.java diff --git a/plugins/com.minres.scviewer.database.fst/src/com/minres/scviewer/database/fst/FstLibrary.java b/plugins/com.minres.scviewer.database.fst/src/com/minres/scviewer/database/fst/FstLibrary.java index 5b6871b..5654025 100644 --- a/plugins/com.minres.scviewer.database.fst/src/com/minres/scviewer/database/fst/FstLibrary.java +++ b/plugins/com.minres.scviewer.database.fst/src/com/minres/scviewer/database/fst/FstLibrary.java @@ -1,7 +1,6 @@ package com.minres.scviewer.database.fst; import com.sun.jna.Native; -import com.sun.jna.Platform; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Structure.FieldOrder; diff --git a/plugins/com.minres.scviewer.database.ftr/src/com/minres/scviewer/database/ftr/FtrDbLoader.java b/plugins/com.minres.scviewer.database.ftr/src/com/minres/scviewer/database/ftr/FtrDbLoader.java index d84610d..53a1736 100644 --- a/plugins/com.minres.scviewer.database.ftr/src/com/minres/scviewer/database/ftr/FtrDbLoader.java +++ b/plugins/com.minres.scviewer.database.ftr/src/com/minres/scviewer/database/ftr/FtrDbLoader.java @@ -33,7 +33,6 @@ import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.EventKind; import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDbLoader; import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.RelationType; diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java index 563af11..31c7b96 100644 --- a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java +++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoader.java @@ -46,7 +46,6 @@ import com.minres.scviewer.database.AssociationType; import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.EventKind; import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDbLoader; import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.RelationType; diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/TrackEntryGroup.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/TrackEntryGroup.java new file mode 100644 index 0000000..00973b2 --- /dev/null +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/TrackEntryGroup.java @@ -0,0 +1,21 @@ +package com.minres.scviewer.database.ui; + +import java.util.ArrayList; +import java.util.List; + +import com.minres.scviewer.database.BlankWaveform; + +public class TrackEntryGroup extends TrackEntry { + + public List waveforms = new ArrayList<>(); + + public Boolean is_open = true; + + public TrackEntryGroup(TrackEntry[] waveform, IWaveformStyleProvider styleProvider) { + super(new BlankWaveform(), styleProvider); + for (TrackEntry iWaveform : waveform) { + waveforms.add(iWaveform); + } + } + +} diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/WaveformColors.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/WaveformColors.java index 78340b5..177f10c 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/WaveformColors.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/WaveformColors.java @@ -16,5 +16,5 @@ public enum WaveformColors { TX_BG, TX_BG_HIGHLITE, TX_BORDER, SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL, SIGNAL_NAN, CURSOR, CURSOR_DRAG, CURSOR_TEXT, - MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE + MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE, BLANK } \ No newline at end of file diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/DefaultWaveformStyleProvider.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/DefaultWaveformStyleProvider.java index a0a1e85..9eef6cf 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/DefaultWaveformStyleProvider.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/DefaultWaveformStyleProvider.java @@ -49,6 +49,7 @@ public class DefaultWaveformStyleProvider implements IWaveformStyleProvider { colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA); colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255); + colors[WaveformColors.BLANK.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_RED); } /** * needs redraw() afterwards diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/BlankPainter.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/BlankPainter.java new file mode 100644 index 0000000..d704615 --- /dev/null +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/BlankPainter.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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); + + } +} 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 ace49ff..d93e3a7 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 @@ -47,7 +47,6 @@ import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.PaintEvent; @@ -91,6 +90,7 @@ import com.minres.scviewer.database.ui.IWaveformStyleProvider; import com.minres.scviewer.database.ui.IWaveformView; import com.minres.scviewer.database.ui.IWaveformZoom; import com.minres.scviewer.database.ui.TrackEntry; +import com.minres.scviewer.database.ui.TrackEntryGroup; import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar; public class WaveformView implements IWaveformView { @@ -137,7 +137,7 @@ public class WaveformView implements IWaveformView { protected TrackEntry lastClickedEntry; - protected MouseListener nameValueMouseListener = new MouseAdapter() { + protected MouseListener nameValueMouseListener = new MouseListener() { @Override public void mouseDown(MouseEvent e) { @@ -173,6 +173,10 @@ public class WaveformView implements IWaveformView { } } } + + @Override + public void mouseDoubleClick(MouseEvent e) { + } }; class WaveformMouseListener implements PaintListener, Listener { @@ -551,29 +555,30 @@ public class WaveformView implements IWaveformView { public void update() { tracksVerticalHeight = 0; int nameMaxWidth = 0; - IWaveformPainter painter = null; trackVerticalOffset.clear(); waveformCanvas.clearAllWaveformPainter(false); boolean even = true; TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); tl.setFont(styleProvider.getNameFont()); for (TrackEntry streamEntry : streams) { - streamEntry.height = styleProvider.getTrackHeight(); - streamEntry.vOffset = tracksVerticalHeight; - if (streamEntry.waveform.getType() == WaveformType.TRANSACTION) { - streamEntry.currentValue = ""; - streamEntry.height *= streamEntry.waveform.getRowCount(); - painter = new StreamPainter(waveformCanvas, even, streamEntry); - } else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) { - streamEntry.currentValue = "---"; - painter = new SignalPainter(waveformCanvas, even, streamEntry); + if(streamEntry instanceof TrackEntryGroup && ((TrackEntryGroup)streamEntry).is_open) { + TrackEntryGroup streamEntryGroup = (TrackEntryGroup)streamEntry; + for (TrackEntry trackEntry : streamEntryGroup.waveforms) { + addPainter(even, trackEntry); + trackVerticalOffset.put(tracksVerticalHeight, trackEntry); + tl.setText(trackEntry.waveform.getFullName()); + nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width); + tracksVerticalHeight += trackEntry.height; + even = !even; + } + } else { + addPainter(even, streamEntry); + trackVerticalOffset.put(tracksVerticalHeight, streamEntry); + tl.setText(streamEntry.waveform.getFullName()); + nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width); + tracksVerticalHeight += streamEntry.height; + even = !even; } - waveformCanvas.addWaveformPainter(painter, false); - trackVerticalOffset.put(tracksVerticalHeight, streamEntry); - tl.setText(streamEntry.waveform.getFullName()); - nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width); - tracksVerticalHeight += streamEntry.height; - even = !even; } waveformCanvas.syncSb(); nameList.setSize(nameMaxWidth + 15, tracksVerticalHeight); @@ -588,6 +593,23 @@ public class WaveformView implements IWaveformView { tl.dispose(); } + private void addPainter(boolean even, TrackEntry streamEntry) { + streamEntry.height = styleProvider.getTrackHeight(); + streamEntry.vOffset = tracksVerticalHeight; + if (streamEntry.waveform.getType() == WaveformType.TRANSACTION) { + streamEntry.currentValue = ""; + streamEntry.height *= streamEntry.waveform.getRowCount(); + IWaveformPainter painter = new StreamPainter(waveformCanvas, even, streamEntry); + waveformCanvas.addWaveformPainter(painter, false); + } else if (streamEntry.waveform.getType() == WaveformType.SIGNAL) { + streamEntry.currentValue = "---"; + waveformCanvas.addWaveformPainter(new SignalPainter(waveformCanvas, even, streamEntry), false); + } else if (streamEntry.waveform.getType() == WaveformType.BLANK) { + streamEntry.currentValue = ""; + waveformCanvas.addWaveformPainter(new BlankPainter(waveformCanvas, even, streamEntry), false); + } + } + private int calculateValueWidth() { TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); tl.setFont(styleProvider.getNameFontHighlite()); diff --git a/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java b/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java index 1801a50..853f87b 100644 --- a/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java +++ b/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoader.java @@ -28,7 +28,6 @@ import com.minres.scviewer.database.BitVector; import com.minres.scviewer.database.DoubleVal; import com.minres.scviewer.database.IEventList; import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDbLoader; import com.minres.scviewer.database.InputFormatException; import com.minres.scviewer.database.RelationType; diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/BlankWaveform.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/BlankWaveform.java new file mode 100644 index 0000000..c4c0752 --- /dev/null +++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/BlankWaveform.java @@ -0,0 +1,104 @@ +package com.minres.scviewer.database; + +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +public class BlankWaveform implements IWaveform { + + @Override + public void addPropertyChangeListener(PropertyChangeListener l) { + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener l) { + } + + @Override + public String getFullName() { + return ""; + } + + @Override + public String getName() { + return ""; + } + + @Override + public void setName(String name) { + } + + @Override + public void setParent(IHierNode parent) { + } + + @Override + public IHierNode getParent() { + return null; + } + + @Override + public List getChildNodes() { + return new ArrayList<>(); + } + + @Override + public void addChild(IHierNode child) { + } + + @Override + public IDerivedWaveform deriveWaveform() { + return null; + } + + @Override + public int compareTo(IHierNode o) { + return 1; + } + + @Override + public long getId() { + return 0; + } + + @Override + public boolean isSame(IWaveform other) { + return false; + } + + @Override + public IEventList getEvents() { + return new EventList(); + } + + @Override + public IEvent[] getEventsAtTime(long time) { + return new IEvent[0]; + } + + @Override + public IEvent[] getEventsBeforeTime(long time) { + return new IEvent[0]; + } + + @Override + public WaveformType getType() { + return WaveformType.BLANK; + } + + @Override + public String getKind() { + return "BLANK"; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public int getWidth() { + return 0; + } + +} diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/WaveformType.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/WaveformType.java index 209f3c9..6da5ed6 100644 --- a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/WaveformType.java +++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/WaveformType.java @@ -20,5 +20,7 @@ public enum WaveformType { /** The transaction. */ TRANSACTION, /** The filter. */ - FILTER + FILTER, + /** The blank line. */ + BLANK } diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi index f896b0f..3245ad3 100644 --- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi +++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi @@ -117,6 +117,7 @@ + type:user @@ -200,6 +201,13 @@ + + + + + + + @@ -278,6 +286,9 @@ + + + diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java index e2e8142..0deead7 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java @@ -84,6 +84,11 @@ public class Messages extends NLS { public static String cursor; public static String cursor_drag; public static String cursor_text; + public static String marker; + public static String marker_text; + public static String rel_arrow; + public static String rel_arrow_highlite; + public static String blank; public static String HelpBrowser_0; public static String HelpBrowser_1; public static String HelpBrowser_2; @@ -92,10 +97,6 @@ public class Messages extends NLS { public static String HelpBrowser_5; public static String HelpBrowser_7; public static String HelpBrowser_8; - public static String marker; - public static String marker_text; - public static String rel_arrow; - public static String rel_arrow_highlite; public static String UpdateHandler_URI; public static String UpdateHandler_10; public static String UpdateHandler_11; diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddBlankWaveformHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddBlankWaveformHandler.java new file mode 100644 index 0000000..3055d93 --- /dev/null +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/AddBlankWaveformHandler.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2023 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.e4.application.handlers; + +import javax.inject.Named; + +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.viewers.IStructuredSelection; + +import com.minres.scviewer.database.BlankWaveform; +import com.minres.scviewer.database.IWaveform; +import com.minres.scviewer.database.ui.TrackEntry; +import com.minres.scviewer.e4.application.parts.WaveformViewer; + +public class AddBlankWaveformHandler { + + public static final String PARAM_WHERE_ID="com.minres.scviewer.e4.application.commandparameter.add_blank"; //$NON-NLS-1$ + + @CanExecute + public Boolean canExecute(EPartService partService){ + MPart part = partService.getActivePart(); + if(part!=null && part.getObject() instanceof WaveformViewer){ + Object sel = ((WaveformViewer)part.getObject()).getSelection(); + if( sel instanceof IStructuredSelection) { + if(((IStructuredSelection)sel).isEmpty()) return false; + Object o= ((IStructuredSelection)sel).getFirstElement(); + return o instanceof TrackEntry; + } + } + return false; + } + + @Execute + public void execute(@Named(PARAM_WHERE_ID) String where, EPartService partService) { + Object obj = partService.getActivePart().getObject(); + if(obj instanceof WaveformViewer){ + ((WaveformViewer)obj).addStreamsToList( + new IWaveform[]{new BlankWaveform()}, "before".equalsIgnoreCase(where)); //$NON-NLS-1$ + } + } + +} diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java index 4d2a491..eb47169 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/MoveWaveformHandler.java @@ -17,11 +17,8 @@ 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.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.jface.viewers.IStructuredSelection; -import com.minres.scviewer.database.IWaveform; -import com.minres.scviewer.database.tx.ITx; import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.e4.application.parts.WaveformViewer; @@ -30,11 +27,15 @@ public class MoveWaveformHandler { static final String PARAMETER_ID="com.minres.scviewer.e4.application.command.movewaveformupCommand.parameter.dir"; //$NON-NLS-1$ @CanExecute - public Boolean canExecute(ESelectionService selectionService){ - Object sel = selectionService.getSelection(); - if( sel instanceof IStructuredSelection) { - Object o= ((IStructuredSelection)sel).getFirstElement(); - return o instanceof IWaveform || o instanceof ITx | o instanceof TrackEntry; + public Boolean canExecute(EPartService partService){ + MPart part = partService.getActivePart(); + if(part!=null && part.getObject() instanceof WaveformViewer){ + Object sel = ((WaveformViewer)part.getObject()).getSelection(); + if( sel instanceof IStructuredSelection) { + if(((IStructuredSelection)sel).isEmpty()) return false; + Object o= ((IStructuredSelection)sel).getFirstElement(); + return o instanceof TrackEntry; + } } return false; } diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties index 140b8a3..d040925 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties @@ -45,7 +45,7 @@ WaveformPopupMenuContribution_10=No command found\! WaveformPopupMenuContribution_12=Render {0} WaveformPopupMenuContribution_15=No command found\! WaveformPreferencesPage_description=Default Waveform Window Settings -WaveformPreferencesPage_1=Color for +WaveformPreferencesPage_1=Color for {0} WaveformViewer_14=Database Load Cancelled WaveformViewer_15=Database Load Job WaveformViewer_16=Loading @@ -78,18 +78,11 @@ signal_nan=Signal NaN Value cursor=Cursor cursor_drag=dragged Cursor cursor_text=Cursor Text -HelpBrowser_0=Back -HelpBrowser_1=Forward -HelpBrowser_2=Stop -HelpBrowser_3=Refresh -HelpBrowser_4=Go -HelpBrowser_5=Address -HelpBrowser_7=Error initializing help browser -HelpBrowser_8=An error occurred while initializing the help browser: marker=Marker marker_text=Marker TExt rel_arrow=Relation arrow rel_arrow_highlite=highlighted Relation arrorw +blank=blank waveform entry UpdateHandler_URI=http://https://minres.github.io/SCViewer/repository UpdateHandler_10=Information UpdateHandler_11=Error @@ -101,3 +94,11 @@ UpdateHandler_6=Updates installed, restart? UpdateHandler_7=Updates have been installed successfully, do you want to restart? UpdateHandler_8=Couldn't get provisioning job: UpdateHandler_9=Couldn't resolve provisioning job +HelpBrowser_0=Back +HelpBrowser_1=Forward +HelpBrowser_2=Stop +HelpBrowser_3=Refresh +HelpBrowser_4=Go +HelpBrowser_5=Address +HelpBrowser_7=Error initializing help browser +HelpBrowser_8=An error occurred while initializing the help browser: diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformStyleProvider.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformStyleProvider.java index b2f389f..ae5eb0a 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformStyleProvider.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformStyleProvider.java @@ -16,6 +16,7 @@ import org.osgi.service.prefs.Preferences; import com.minres.scviewer.database.ui.IWaveformStyleProvider; import com.minres.scviewer.database.ui.WaveformColors; +import com.minres.scviewer.database.ui.swt.DefaultWaveformStyleProvider; import com.minres.scviewer.e4.application.preferences.PreferenceConstants; public class WaveformStyleProvider implements IWaveformStyleProvider { @@ -39,29 +40,9 @@ public class WaveformStyleProvider implements IWaveformStyleProvider { Display display = Display.getCurrent(); nameFont = display.getSystemFont(); - colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN); - colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK); - colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40); - colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80); - colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); - colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); - colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); - colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); - colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); - colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); - colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); - colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); - colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); - colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); - colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); - colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY); - colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); - colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA); - colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255); + DefaultWaveformStyleProvider x = new DefaultWaveformStyleProvider(); + for (WaveformColors color : WaveformColors.values()) + colors[color.ordinal()] = x.getColor(color); randomColors = new Color[][] { { SWTResourceManager.getColor( 170, 66, 37 ), SWTResourceManager.getColor( 190, 66, 37 ) }, { SWTResourceManager.getColor( 96, 74, 110 ), SWTResourceManager.getColor( 96, 74, 130 ) }, diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index 930e6d7..c5c7553 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -14,64 +14,30 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.resource.StringConverter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.wb.swt.SWTResourceManager; import org.osgi.framework.FrameworkUtil; import com.minres.scviewer.database.ui.WaveformColors; +import com.minres.scviewer.database.ui.swt.DefaultWaveformStyleProvider; /** * The Class DefaultValuesInitializer. */ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { - /** The default colors. */ - public static final Color[] colors = new Color[WaveformColors.values().length]; - - /** - * Instantiates a new default values initializer. - */ - public DefaultValuesInitializer() { - colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN); - colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK); - colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40); - colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80); - colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); - colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN); - colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); - colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); - colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); - colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); - colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); - colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); - colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); - colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); - colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); - colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); - colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); - colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY); - colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); - colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA); - colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255); - } - /* (non-Javadoc) * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ @Override public void initializeDefaultPreferences() { IEclipsePreferences store = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(getClass()).getSymbolicName()); + DefaultWaveformStyleProvider styleProvider = new DefaultWaveformStyleProvider(); store.putBoolean(PreferenceConstants.DATABASE_RELOAD, true); store.putBoolean(PreferenceConstants.SHOW_HOVER, true); store.putBoolean(PreferenceConstants.SHOW_TX_DETAILS, false); store.putInt(PreferenceConstants.TRACK_HEIGHT, 30); for (WaveformColors c : WaveformColors.values()) { - store.put(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ + store.put(c.name()+"_COLOR", StringConverter.asString(styleProvider.getColor(c).getRGB())); //$NON-NLS-1$ } } diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java index 86fd48e..5de22b4 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java @@ -32,59 +32,5 @@ public class PreferenceConstants { /** The Constant TRACK_HEIGHT. */ public static final String TRACK_HEIGHT="trackHeigth"; //$NON-NLS-1$ - /** The Constant LINE_COLOR. */ - public static final String LINE_COLOR="LINE_COLOR"; //$NON-NLS-1$ - - /** The Constant LINE_HIGHLITE_COLOR. */ - public static final String LINE_HIGHLITE_COLOR="LINE_HIGHLITE_COLOR"; //$NON-NLS-1$ - - /** The Constant TRACK_BG_EVEN_COLOR. */ - public static final String TRACK_BG_EVEN_COLOR="TRACK_BG_EVEN_COLOR"; //$NON-NLS-1$ - - /** The Constant TRACK_BG_ODD_COLOR. */ - public static final String TRACK_BG_ODD_COLOR="TRACK_BG_ODD_COLOR"; //$NON-NLS-1$ - - /** The Constant TRACK_BG_HIGHLITE_COLOR. */ - public static final String TRACK_BG_HIGHLITE_COLOR="TRACK_BG_HIGHLITE_COLOR"; //$NON-NLS-1$ - - /** The Constant TX_BG_COLOR. */ - public static final String TX_BG_COLOR="TX_BG_COLOR"; //$NON-NLS-1$ - - /** The Constant TX_BG_HIGHLITE_COLOR. */ - public static final String TX_BG_HIGHLITE_COLOR="TX_BG_HIGHLITE_COLOR"; //$NON-NLS-1$ - - /** The Constant TX_BORDER_COLOR. */ - public static final String TX_BORDER_COLOR="TX_BORDER_COLOR"; //$NON-NLS-1$ - - /** The Constant SIGNAL0_COLOR. */ - public static final String SIGNAL0_COLOR="SIGNAL0_COLOR"; //$NON-NLS-1$ - - /** The Constant SIGNAL1_COLOR. */ - public static final String SIGNAL1_COLOR="SIGNAL1_COLOR"; //$NON-NLS-1$ - - /** The Constant SIGNALZ_COLOR. */ - public static final String SIGNALZ_COLOR="SIGNALZ_COLOR"; //$NON-NLS-1$ - - /** The Constant SIGNALX_COLOR. */ - public static final String SIGNALX_COLOR="SIGNALX_COLOR"; //$NON-NLS-1$ - - /** The Constant SIGNAL_TEXT_COLOR. */ - public static final String SIGNAL_TEXT_COLOR="SIGNAL_TEXT_COLOR"; //$NON-NLS-1$ - - /** The Constant CURSOR_COLOR. */ - public static final String CURSOR_COLOR="CURSOR_COLOR"; //$NON-NLS-1$ - - /** The Constant CURSOR_DRAG_COLOR. */ - public static final String CURSOR_DRAG_COLOR="CURSOR_DRAG_COLOR"; //$NON-NLS-1$ - - /** The Constant CURSOR_TEXT_COLOR. */ - public static final String CURSOR_TEXT_COLOR="CURSOR_TEXT_COLOR"; //$NON-NLS-1$ - - /** The Constant MARKER_COLOR. */ - public static final String MARKER_COLOR="MARKER_COLOR"; //$NON-NLS-1$ - - /** The Constant MARKER_TEXT_COLOR. */ - public static final String MARKER_TEXT_COLOR="MARKER_TEXT_COLOR"; //$NON-NLS-1$ - private PreferenceConstants() {} } diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java index 79ce4fb..0f96a4b 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/WaveformPreferencesPage.java @@ -15,6 +15,7 @@ import java.util.HashMap; import org.eclipse.jface.preference.ColorFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.osgi.util.NLS; import com.minres.scviewer.database.ui.WaveformColors; import com.minres.scviewer.e4.application.Messages; @@ -48,7 +49,7 @@ public class WaveformPreferencesPage extends FieldEditorPreferencePage { } for (WaveformColors c : WaveformColors.values()) { addField(new ColorFieldEditor(c.name() + "_COLOR", - Messages.WaveformPreferencesPage_1 + staticFields.get(c.name().toLowerCase()), //$NON-NLS-1$ + NLS.bind(Messages.WaveformPreferencesPage_1, staticFields.get(c.name().toLowerCase())), //$NON-NLS-1$ getFieldEditorParent())); } }