From ff87e7251050e0b9a914744a88cbdfe4c3065799 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Nov 2021 10:52:59 +0100 Subject: [PATCH 1/4] allow multiple loading of same format --- .../.classpath | 2 +- .../OSGI-INF/component.xml | 6 +- .../database/text/TextDbLoaderFactory.java | 77 +++++++++++++++++++ .../OSGI-INF/component.xml | 6 +- .../scviewer/database/vcd/VCDDbLoader.java | 3 +- .../database/vcd/VCDDbLoaderFactory.java | 77 +++++++++++++++++++ .../OSGI-INF/component.xml | 2 +- .../database/IWaveformDbLoaderFactory.java | 33 ++++++++ .../database/internal/WaveformDb.java | 20 ++--- 9 files changed, 208 insertions(+), 18 deletions(-) create mode 100644 plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoaderFactory.java create mode 100644 plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoaderFactory.java create mode 100644 plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoaderFactory.java diff --git a/plugins/com.minres.scviewer.database.text/.classpath b/plugins/com.minres.scviewer.database.text/.classpath index 3f4be5c..047d7de 100644 --- a/plugins/com.minres.scviewer.database.text/.classpath +++ b/plugins/com.minres.scviewer.database.text/.classpath @@ -2,12 +2,12 @@ + - diff --git a/plugins/com.minres.scviewer.database.text/OSGI-INF/component.xml b/plugins/com.minres.scviewer.database.text/OSGI-INF/component.xml index 2d260e4..12f186e 100644 --- a/plugins/com.minres.scviewer.database.text/OSGI-INF/component.xml +++ b/plugins/com.minres.scviewer.database.text/OSGI-INF/component.xml @@ -1,7 +1,7 @@ - - + + - + diff --git a/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoaderFactory.java b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoaderFactory.java new file mode 100644 index 0000000..2324ff4 --- /dev/null +++ b/plugins/com.minres.scviewer.database.text/src/com/minres/scviewer/database/text/TextDbLoaderFactory.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2012 IT Just working. + * Copyright (c) 2020 MINRES Technologies GmbH + * 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: + * IT Just working - initial API and implementation + *******************************************************************************/ +package com.minres.scviewer.database.text; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; + +import com.minres.scviewer.database.IWaveformDbLoader; +import com.minres.scviewer.database.IWaveformDbLoaderFactory; + +/** + * The Class TextDbLoader. + */ +public class TextDbLoaderFactory implements IWaveformDbLoaderFactory { + + /** The Constant x. */ + static final byte[] x = "scv_tr_stream".getBytes(); + + /** + * Checks if f is gzipped. + * + * @param f the f + * @return true, if is gzipped + */ + private static boolean isGzipped(File f) { + try (InputStream is = new FileInputStream(f)) { + byte[] signature = new byte[2]; + int nread = is.read(signature); // read the gzip signature + return nread == 2 && signature[0] == (byte) 0x1f && signature[1] == (byte) 0x8b; + } catch (IOException e) { + return false; + } + } + + /** + * Can load. + * + * @param inputFile the input file + * @return true, if successful + */ + @Override + public boolean canLoad(File inputFile) { + if (!inputFile.isDirectory() && inputFile.exists()) { + boolean gzipped = isGzipped(inputFile); + try(InputStream stream = gzipped ? new GZIPInputStream(new FileInputStream(inputFile)) : new FileInputStream(inputFile)){ + byte[] buffer = new byte[x.length]; + int readCnt = stream.read(buffer, 0, x.length); + if (readCnt == x.length) { + for (int i = 0; i < x.length; i++) + if (buffer[i] != x[i]) + return false; + } + return true; + } catch (Exception e) { + return false; + } + } + return false; + } + + @Override + public IWaveformDbLoader getLoader() { + return new TextDbLoader(); + } +} diff --git a/plugins/com.minres.scviewer.database.vcd/OSGI-INF/component.xml b/plugins/com.minres.scviewer.database.vcd/OSGI-INF/component.xml index a7d284e..d998cde 100644 --- a/plugins/com.minres.scviewer.database.vcd/OSGI-INF/component.xml +++ b/plugins/com.minres.scviewer.database.vcd/OSGI-INF/component.xml @@ -1,7 +1,7 @@ - - + + - + 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 1bf27e9..57f19f1 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 @@ -164,7 +164,8 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder { @Override public void enterModule(String tokenString) { if(moduleStack.isEmpty()) { - if("SystemC".compareTo(tokenString)!=0) moduleStack.push(tokenString); + if("SystemC".compareTo(tokenString)!=0) + moduleStack.push(tokenString); } else moduleStack.push(moduleStack.peek()+"."+tokenString); diff --git a/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoaderFactory.java b/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoaderFactory.java new file mode 100644 index 0000000..5bab7ec --- /dev/null +++ b/plugins/com.minres.scviewer.database.vcd/src/com/minres/scviewer/database/vcd/VCDDbLoaderFactory.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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.vcd; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; + +import com.minres.scviewer.database.IWaveformDbLoader; +import com.minres.scviewer.database.IWaveformDbLoaderFactory; + +/** + * The Class VCDDb. + */ +public class VCDDbLoaderFactory implements IWaveformDbLoaderFactory { + /** + * Checks if is gzipped. + * + * @param f the f + * @return true, if is gzipped + */ + private static boolean isGzipped(File f) { + try (InputStream is = new FileInputStream(f)) { + byte [] signature = new byte[2]; + int nread = is.read( signature ); //read the gzip signature + return nread == 2 && signature[ 0 ] == (byte) 0x1f && signature[ 1 ] == (byte) 0x8b; + } + catch (IOException e) { + return false; + } + } + + + /** + * Can load. + * + * @param inputFile the input file + * @return true, if successful + */ + @Override + public boolean canLoad(File inputFile) { + if(!inputFile.isDirectory() || inputFile.exists()) { + String name = inputFile.getName(); + if(!(name.endsWith(".vcd") || + name.endsWith(".vcdz") || + name.endsWith(".vcdgz") || + name.endsWith(".vcd.gz")) ) + return false; + boolean gzipped = isGzipped(inputFile); + try(InputStream stream = gzipped ? new GZIPInputStream(new FileInputStream(inputFile)) : new FileInputStream(inputFile)){ + byte[] buffer = new byte[8]; + if (stream.read(buffer, 0, buffer.length) == buffer.length) { + return buffer[0]=='$'; + } + } catch (Exception e) { + return false; + } + } + return false; + } + + + @Override + public IWaveformDbLoader getLoader() { + return new VCDDbLoader(); + } +} diff --git a/plugins/com.minres.scviewer.database/OSGI-INF/component.xml b/plugins/com.minres.scviewer.database/OSGI-INF/component.xml index e313c27..d3f7df9 100644 --- a/plugins/com.minres.scviewer.database/OSGI-INF/component.xml +++ b/plugins/com.minres.scviewer.database/OSGI-INF/component.xml @@ -1,5 +1,5 @@ - + diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoaderFactory.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoaderFactory.java new file mode 100644 index 0000000..c983e67 --- /dev/null +++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/IWaveformDbLoaderFactory.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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; + +import java.io.File; + +/** + * A factory for creating IWaveformDb objects. + */ +public interface IWaveformDbLoaderFactory { + + /** + * Check if the loader produced by this factory can load the given file. + * + * @param inputFile the input file + * @return true, if successful + */ + public boolean canLoad(File inputFile); + /** + * Gets the database. + * + * @return the database + */ + IWaveformDbLoader getLoader(); +} diff --git a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java index 3c5a976..093f9c2 100644 --- a/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java +++ b/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/internal/WaveformDb.java @@ -25,6 +25,7 @@ import com.minres.scviewer.database.IHierNode; import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDbLoader; +import com.minres.scviewer.database.IWaveformDbLoaderFactory; import com.minres.scviewer.database.RelationType; /** @@ -33,7 +34,7 @@ import com.minres.scviewer.database.RelationType; public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeListener { /** The loaders. */ - private static List loaders = new LinkedList<>(); + private static List loaderFactories = new LinkedList<>(); /** The loaded. */ private boolean loaded; @@ -52,8 +53,8 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL * * @param loader the loader */ - public synchronized void bind(IWaveformDbLoader loader) { - loaders.add(loader); + public synchronized void bind(IWaveformDbLoaderFactory loader) { + loaderFactories.add(loader); } /** @@ -61,8 +62,8 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL * * @param loader the loader */ - public synchronized void unbind(IWaveformDbLoader loader) { - loaders.remove(loader); + public synchronized void unbind(IWaveformDbLoaderFactory loader) { + loaderFactories.remove(loader); } /** @@ -70,8 +71,8 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL * * @return the loaders */ - public static List getLoaders() { - return Collections.unmodifiableList(loaders); + public static List getLoaders() { + return Collections.unmodifiableList(loaderFactories); } /** @@ -124,8 +125,9 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL @Override public boolean load(File inp) { boolean retval = true; - for (IWaveformDbLoader loader : loaders) { - if (loader.canLoad(inp)) { + for (IWaveformDbLoaderFactory loaderFactory : loaderFactories) { + if (loaderFactory.canLoad(inp)) { + IWaveformDbLoader loader = loaderFactory.getLoader(); loader.addPropertyChangeListener(this); try { loader.load(this, inp); From 36f628c365aa888ce687c8ee49df6b9d5f7f6c07 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Nov 2021 13:07:22 +0100 Subject: [PATCH 2/4] add help dialog --- .../ui/swt/internal/WaveformView.java | 115 ++++++------ .../Application.e4xmi | 6 +- .../e4/application/handlers/HelpHandler.java | 31 ++++ .../e4/application/parts/AboutDialog.java | 4 +- .../e4/application/parts/HelpDialog.java | 175 ++++++++++++++++++ 5 files changed, 274 insertions(+), 57 deletions(-) create mode 100644 plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/HelpHandler.java create mode 100644 plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/HelpDialog.java 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 9158736..23360c2 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 @@ -164,7 +164,7 @@ public class WaveformView implements IWaveformView { setSelection(new StructuredSelection(res), (e.stateMask & SWT.CTRL) != 0, false); } else setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, - false); + false); } else { setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) != 0, false); } @@ -197,59 +197,64 @@ public class WaveformView implements IWaveformView { down = false; if (start == null) return; - if ((e.stateMask & SWT.MODIFIER_MASK & ~SWT.SHIFT) != 0) - return; // don't react on modifier except shift - if (e.button == 1 && Math.abs(e.x - start.x) > 3) { - asyncUpdate(e.widget); - long startTime = waveformCanvas.getTimeForOffset(start.x); - long endTime = waveformCanvas.getTimeForOffset(end.x); - long targetTimeRange = endTime - startTime; - long currentTimeRange = waveformCanvas.getMaxVisibleTime() - waveformCanvas.getMinVisibleTime(); - if (targetTimeRange == 0) - return; - long relation = currentTimeRange / targetTimeRange; - long i = 1; - int level = 0; - do { - if (relation < 0) { - if (-relation < i) { - break; - } - level--; - if (-relation < i * 3) { - break; - } - level--; - } else { - if (relation < i) { - break; - } - level++; - if (relation < i * 3) { - break; - } - level++; - } - i = i * 10; - } while (i < 10000); - if (i < 10000) { - int curLevel = waveformCanvas.getZoomLevel(); - waveformCanvas.setZoomLevel(curLevel - level, (startTime + endTime) / 2); - } - } else if (e.button == 1 && ((e.stateMask & SWT.SHIFT) == 0)) { - // set cursor (button 1 and no shift) - if (Math.abs(e.x - start.x) < 3 && Math.abs(e.y - start.y) < 3) { - // first set cursor time - setCursorTime(snapOffsetToEvent(start)); - // then set selection and reveal - setSelection(new StructuredSelection(initialSelected)); + if ((e.stateMask & SWT.MODIFIER_MASK & ~(SWT.SHIFT | SWT.CTRL)) != 0) + return; // don't react on modifier except shift and control + boolean isCtrl = (e.stateMask & SWT.CTRL)!=0; + boolean isShift = (e.stateMask & SWT.SHIFT)!=0; + if (e.button == 1) { + if (Math.abs(e.x - start.x) > 3) { // was drag event asyncUpdate(e.widget); + long startTime = waveformCanvas.getTimeForOffset(start.x); + long endTime = waveformCanvas.getTimeForOffset(end.x); + long targetTimeRange = endTime - startTime; + long currentTimeRange = waveformCanvas.getMaxVisibleTime() - waveformCanvas.getMinVisibleTime(); + if (targetTimeRange == 0) + return; + long relation = currentTimeRange / targetTimeRange; + long i = 1; + int level = 0; + do { + if (relation < 0) { + if (-relation < i) { + break; + } + level--; + if (-relation < i * 3) { + break; + } + level--; + } else { + if (relation < i) { + break; + } + level++; + if (relation < i * 3) { + break; + } + level++; + } + i = i * 10; + } while (i < 10000); + if (i < 10000) { + int curLevel = waveformCanvas.getZoomLevel(); + waveformCanvas.setZoomLevel(curLevel - level, (startTime + endTime) / 2); + } + } else if( isShift) { // set marker (button 1 and shift) + setMarkerTime(snapOffsetToEvent(start), selectedMarker); + } else if(isCtrl) { // set cursor (button 1 and ctrl) + setCursorTime(snapOffsetToEvent(start)); + } else { // set cursor (button 1 only) + if (Math.abs(e.y - start.y) < 3) { + // first set cursor time + setCursorTime(snapOffsetToEvent(start)); + // then set selection and reveal + setSelection(new StructuredSelection(initialSelected)); + } } - } else if (e.button == 2 || (e.button == 1 && (e.stateMask & SWT.SHIFT) != 0)) { - // set marker (button 1 and shift) + } else if (e.button == 2) { // set marker (button 2) setMarkerTime(snapOffsetToEvent(start), selectedMarker); - asyncUpdate(e.widget); } + asyncUpdate(e.widget); } protected long snapOffsetToEvent(Point p) { @@ -287,8 +292,8 @@ public class WaveformView implements IWaveformView { @Override public void handleEvent(Event e) { switch (e.type) { - case SWT.MouseWheel: - break; +// case SWT.MouseWheel: +// break; case SWT.MouseDown: start = new Point(e.x, e.y); end = new Point(e.x, e.y); @@ -756,7 +761,7 @@ public class WaveformView implements IWaveformView { ITx txSel = (ITx) selList.get(0); TrackEntry trackEntry = selList.size() == 2 && selList.get(1) instanceof TrackEntry ? (TrackEntry) selList.get(1) - : null; + : null; if (trackEntry == null) { trackEntry = getEntryFor(txSel); if (trackEntry == null && addIfNeeded) { @@ -930,7 +935,7 @@ public class WaveformView implements IWaveformView { return candidates.get(0); default: ArrayList visibleCandidates = candidates.stream().filter(this::streamsVisible) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(Collectors.toCollection(ArrayList::new)); if (visibleCandidates.isEmpty()) { return new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open(); } else if (visibleCandidates.size() == 1) { @@ -1230,7 +1235,7 @@ public class WaveformView implements IWaveformView { if (event.y < tracksVerticalHeight) { event.doit = true; LocalSelectionTransfer.getTransfer() - .setSelection(new StructuredSelection(currentWaveformSelection)); + .setSelection(new StructuredSelection(currentWaveformSelection)); } } diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi index bdf9b97..85f4ea6 100644 --- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi +++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi @@ -9,6 +9,7 @@ + @@ -55,7 +56,8 @@ - + + @@ -139,6 +141,7 @@ + type:user @@ -280,6 +283,7 @@ + diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/HelpHandler.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/HelpHandler.java new file mode 100644 index 0000000..8602148 --- /dev/null +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/HelpHandler.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.e4.application.handlers; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +import org.eclipse.e4.ui.model.application.ui.basic.MWindow; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.swt.widgets.Shell; + +public class HelpHandler { + + static final String DIALOG_ID="com.minres.scviewer.e4.application.dialog.onlinehelp"; + + @Execute + public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) { + MPart mel = (MPart) ms.find(DIALOG_ID, app); //$NON-NLS-1$ + mel.setToBeRendered(true); + mel.setToBeRendered(false); + } + +} diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java index c5a96bf..caccf88 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java @@ -131,7 +131,9 @@ public class AboutDialog extends Dialog { if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) { Desktop.getDesktop().browse(new java.net.URI(style.data.toString())); } - } catch (IOException | URISyntaxException | IllegalArgumentException e) {} + } catch (IOException | URISyntaxException | IllegalArgumentException e) { + } catch (UnsupportedOperationException e) { + } }); styleRange.start = 0; diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/HelpDialog.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/HelpDialog.java new file mode 100644 index 0000000..e6b97f4 --- /dev/null +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/HelpDialog.java @@ -0,0 +1,175 @@ +package com.minres.scviewer.e4.application.parts; + +import javax.annotation.PostConstruct; +import javax.inject.Inject; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTError; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.browser.LocationListener; +import org.eclipse.swt.browser.ProgressEvent; +import org.eclipse.swt.browser.ProgressListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.ProgressBar; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +public class HelpDialog extends Dialog { + /** + * Create the dialog. + * + * @param parentShell the parent shell + */ + @Inject + public HelpDialog(Shell parentShell) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.MODELESS | SWT.MAX | SWT.BORDER | SWT.TITLE); + setBlockOnOpen(false); + } + + @Override + protected boolean isResizable() { + return true; + } + + @Override + protected Point getInitialSize() { + return new Point(800, 600); + } + + /** + * Create contents of the dialog. + * + * @param parent the parent + * @return the control + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + container.setLayout(gridLayout); + ToolBar toolbar = new ToolBar(container, SWT.NONE); + ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH); + itemBack.setText("Back"); + ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH); + itemForward.setText("Forward"); + ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH); + itemStop.setText("Stop"); + ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH); + itemRefresh.setText("Refresh"); + ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH); + itemGo.setText("Go"); + + GridData data = new GridData(); + data.horizontalSpan = 3; + toolbar.setLayoutData(data); + + Label labelAddress = new Label(container, SWT.NONE); + labelAddress.setText("Address"); + + final Text location = new Text(container, SWT.BORDER); + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.horizontalSpan = 2; + data.grabExcessHorizontalSpace = true; + location.setLayoutData(data); + + final Browser browser; + try { + browser = new Browser(container, SWT.NONE); + data = new GridData(); + // data.widthHint = 800; + // data.heightHint =600; + data.horizontalAlignment = GridData.FILL; + data.verticalAlignment = GridData.FILL; + data.horizontalSpan = 3; + data.grabExcessHorizontalSpace = true; + data.grabExcessVerticalSpace = true; + browser.setLayoutData(data); + + final Label status = new Label(container, SWT.NONE); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + status.setLayoutData(data); + + final ProgressBar progressBar = new ProgressBar(container, SWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.END; + progressBar.setLayoutData(data); + + /* event handling */ + Listener listener = event -> { + ToolItem item = (ToolItem) event.widget; + String string = item.getText(); + if (string.equals("Back")) + browser.back(); + else if (string.equals("Forward")) + browser.forward(); + else if (string.equals("Stop")) + browser.stop(); + else if (string.equals("Refresh")) + browser.refresh(); + else if (string.equals("Go")) + browser.setUrl(location.getText()); + }; + browser.addProgressListener(new ProgressListener() { + @Override + public void changed(ProgressEvent event) { + if (event.total == 0) return; + int ratio = event.current * 100 / event.total; + progressBar.setSelection(ratio); + } + @Override + public void completed(ProgressEvent event) { + progressBar.setSelection(0); + } + }); + browser.addStatusTextListener(event -> status.setText(event.text)); + browser.addLocationListener(LocationListener.changedAdapter(event -> { + if (event.top) location.setText(event.location); + } + )); + itemBack.addListener(SWT.Selection, listener); + itemForward.addListener(SWT.Selection, listener); + itemStop.addListener(SWT.Selection, listener); + itemRefresh.addListener(SWT.Selection, listener); + itemGo.addListener(SWT.Selection, listener); + location.addListener(SWT.DefaultSelection, e -> browser.setUrl(location.getText())); + + browser.setUrl("http://eclipse.org"); + } catch (SWTError e) { + System.out.println("Could not instantiate Browser: " + e.getMessage()); + } + return container; + } + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + // create OK button + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); + } + + /** + * Open the dialog. + * @return the result + */ + @PostConstruct + @Override + public int open() { + return super.open(); + } + +} \ No newline at end of file From 9ea19942285eb27d6ba8153b8f386f938ea10d1f Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Nov 2021 14:16:46 +0100 Subject: [PATCH 3/4] update key bindings --- README.md | 39 +++++++++++++++---- .../scviewer/database/ui/IWaveformView.java | 10 ++++- .../ui/swt/internal/WaveformCanvas.java | 6 +++ .../ui/swt/internal/WaveformView.java | 29 +++++++++++++- .../e4/application/parts/WaveformViewer.java | 4 ++ 5 files changed, 77 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0733877..924b76d 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,35 @@ To build the plugins the Eclipse SDK or PDE can be used. In both cases the Groov eclipse plugin (http://groovy.codehaus.org/Eclipse+Plugin or Market) has to be installed. -TODO -==== -- add more tests -- move to feature based product to allow automatic updates -- improve graphics -- catch-up e3 plugin to functionality of e4 product -- add calculated traces +Key Shortcuts +============= + +Legend: + +* Left Mouse Button: LMB +* Middle Mouse Button: MMB +* Mouse Scroll wheel: MScrl +* Context any means Name List, Value List or Waveform + +| Input | Modifier | Context | Action | +|-----------|----------|----------|-----------------------------------| +| LMB klick | | any | select | +| LMB klick | Shift | Waveform | move selected marker to position | +| LMB klick | Control | Waveform | move cursor to position | +| LMB drag | | Waveform | zoom to range | +| MMB klick | | Waveform | move selected marker to position | +| MScrl | | any | scroll window up/down | +| MScrl | Shift | any | scroll window left/right | +| Key left | | Waveform | scroll window to the left (slow) | +| Key right | | Waveform | scroll window to the right (slow) | +| Key left | Shift | Waveform | scroll window to the left (fast) | +| Key right | Shift | Waveform | scroll window to the right (fast) | +| Key up | | Waveform | move selection up | +| Key down | | Waveform | move selection down | +| Key up | Control | Waveform | move selected track up | +| Key down | Control | Waveform | move selected track down | +| Key + | Control | Waveform | zoom in | +| Key - | Control | Waveform | zoom out | +| Key Pos1 | | Waveform | jump to selected marker | +| Key End | | Waveform | jump to cursor | +| Key Del | | any | delete selected entries | diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java index 0e71ecf..2677577 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/IWaveformView.java @@ -27,10 +27,14 @@ import com.minres.scviewer.database.tx.ITx; public interface IWaveformView extends PropertyChangeListener, ISelectionProvider{ - String CURSOR_PROPERTY = "cursor_time"; + static final String CURSOR_PROPERTY = "cursor_time"; - String MARKER_PROPERTY = "marker_time"; + static final String MARKER_PROPERTY = "marker_time"; + static final int CURSOR_POS = 0; + + static final int MARKER_POS = 1; + public static final RelationType NEXT_PREV_IN_STREAM = RelationTypeFactory.create("Prev/Next in stream"); public void addSelectionChangedListener(ISelectionChangedListener listener); @@ -113,6 +117,8 @@ public interface IWaveformView extends PropertyChangeListener, ISelectionProvide public void scrollHorizontal(int percent); + public void scrollTo(int pos); + public void addDisposeListener( DisposeListener listener ); public void deleteSelectedTracks(); diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java index fe50833..c3839c6 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformCanvas.java @@ -496,6 +496,12 @@ public class WaveformCanvas extends Canvas { } } + public void centerAt(long time) { + int scaledTime = (int) (time / scaleFactor); + int newX = -scaledTime+getWidth()/2; + setOrigin(newX>0?0:newX, origin.y); + } + public int getRulerHeight() { return rulerHeight; } 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 23360c2..e1984fd 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 @@ -292,8 +292,8 @@ public class WaveformView implements IWaveformView { @Override public void handleEvent(Event e) { switch (e.type) { -// case SWT.MouseWheel: -// break; + // case SWT.MouseWheel: + // break; case SWT.MouseDown: start = new Point(e.x, e.y); end = new Point(e.x, e.y); @@ -1509,6 +1509,22 @@ public class WaveformView implements IWaveformView { waveformCanvas.redraw(); } + @Override + public void scrollTo(int pos) { + long time = 0; + switch(pos) { + case IWaveformView.CURSOR_POS: + time = getCursorTime(); + break; + case IWaveformView.MARKER_POS: + time = getMarkerTime(selectedMarker); + break; + default: + break; + } + waveformCanvas.centerAt(time); + } + public void asyncUpdate(Widget widget) { widget.getDisplay().asyncExec(() -> { waveformCanvas.redraw(); @@ -1539,4 +1555,13 @@ public class WaveformView implements IWaveformView { return e; } + + + + + + + + + } 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 7db79ef..387dae6 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 @@ -357,9 +357,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.moveSelection(GotoDirection.DOWN); return; case SWT.HOME: + waveformPane.scrollTo(IWaveformView.MARKER_POS); return; case SWT.END: + waveformPane.scrollTo(IWaveformView.CURSOR_POS); return; + case SWT.DEL: + waveformPane.deleteSelectedTracks(); default: break; } From e0fa55e2c0307a7b6bcc86d54e459e1888c3b544 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Nov 2021 14:32:55 +0100 Subject: [PATCH 4/4] corrected parent path im poms --- .../pom.xml | 2 +- .../com.minres.scviewer.e4.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/com.minres.scviewer.feature/pom.xml | 2 +- .../com.minres.scviewer.ui.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../com.minres.scviewer.database.text/pom.xml | 2 +- .../pom.xml | 2 +- .../com.minres.scviewer.database.vcd/pom.xml | 2 +- plugins/com.minres.scviewer.database/pom.xml | 2 +- .../pom.xml | 4 +- plugins/com.minres.scviewer.ui/pom.xml | 2 +- pom.xml | 152 ------------------ .../com.minres.scviewer.e4.product/pom.xml | 2 +- releng/com.minres.scviewer.target/pom.xml | 2 +- releng/com.minres.scviewer.updateSite/pom.xml | 4 +- .../com.minres.scviewer.database.test/pom.xml | 2 +- 17 files changed, 18 insertions(+), 170 deletions(-) delete mode 100644 pom.xml diff --git a/features/com.minres.scviewer.database.feature/pom.xml b/features/com.minres.scviewer.database.feature/pom.xml index 275ae30..0b7d1f8 100644 --- a/features/com.minres.scviewer.database.feature/pom.xml +++ b/features/com.minres.scviewer.database.feature/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. 3.0.0-SNAPSHOT diff --git a/features/com.minres.scviewer.e4.feature/pom.xml b/features/com.minres.scviewer.e4.feature/pom.xml index 9f3b4d0..ed63681 100644 --- a/features/com.minres.scviewer.e4.feature/pom.xml +++ b/features/com.minres.scviewer.e4.feature/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. 1.1.0-SNAPSHOT diff --git a/features/com.minres.scviewer.e4.platform.feature/pom.xml b/features/com.minres.scviewer.e4.platform.feature/pom.xml index b395bf3..e138214 100644 --- a/features/com.minres.scviewer.e4.platform.feature/pom.xml +++ b/features/com.minres.scviewer.e4.platform.feature/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. 1.0.0-SNAPSHOT diff --git a/features/com.minres.scviewer.feature/pom.xml b/features/com.minres.scviewer.feature/pom.xml index a3c91c6..a1f501d 100644 --- a/features/com.minres.scviewer.feature/pom.xml +++ b/features/com.minres.scviewer.feature/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. 1.1.0-SNAPSHOT diff --git a/features/com.minres.scviewer.ui.feature/pom.xml b/features/com.minres.scviewer.ui.feature/pom.xml index 2ba8af9..7975438 100644 --- a/features/com.minres.scviewer.ui.feature/pom.xml +++ b/features/com.minres.scviewer.ui.feature/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. 1.1.0-SNAPSHOT diff --git a/plugins/com.minres.scviewer.database.sqlite/pom.xml b/plugins/com.minres.scviewer.database.sqlite/pom.xml index 18d93d4..0c3dc59 100644 --- a/plugins/com.minres.scviewer.database.sqlite/pom.xml +++ b/plugins/com.minres.scviewer.database.sqlite/pom.xml @@ -5,7 +5,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-plugin diff --git a/plugins/com.minres.scviewer.database.text/pom.xml b/plugins/com.minres.scviewer.database.text/pom.xml index 6f39c55..057b481 100644 --- a/plugins/com.minres.scviewer.database.text/pom.xml +++ b/plugins/com.minres.scviewer.database.text/pom.xml @@ -7,7 +7,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-plugin diff --git a/plugins/com.minres.scviewer.database.ui.swt/pom.xml b/plugins/com.minres.scviewer.database.ui.swt/pom.xml index 9fed7ec..639d25d 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/pom.xml +++ b/plugins/com.minres.scviewer.database.ui.swt/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. 4.0.0-SNAPSHOT diff --git a/plugins/com.minres.scviewer.database.vcd/pom.xml b/plugins/com.minres.scviewer.database.vcd/pom.xml index 3b61479..51e769c 100644 --- a/plugins/com.minres.scviewer.database.vcd/pom.xml +++ b/plugins/com.minres.scviewer.database.vcd/pom.xml @@ -6,7 +6,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-plugin diff --git a/plugins/com.minres.scviewer.database/pom.xml b/plugins/com.minres.scviewer.database/pom.xml index bd9a308..002335e 100644 --- a/plugins/com.minres.scviewer.database/pom.xml +++ b/plugins/com.minres.scviewer.database/pom.xml @@ -5,7 +5,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-plugin 4.0.0-SNAPSHOT diff --git a/plugins/com.minres.scviewer.e4.application/pom.xml b/plugins/com.minres.scviewer.e4.application/pom.xml index efe352a..d9c7b42 100644 --- a/plugins/com.minres.scviewer.e4.application/pom.xml +++ b/plugins/com.minres.scviewer.e4.application/pom.xml @@ -7,7 +7,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-plugin - \ No newline at end of file + diff --git a/plugins/com.minres.scviewer.ui/pom.xml b/plugins/com.minres.scviewer.ui/pom.xml index dd14c15..6583a40 100644 --- a/plugins/com.minres.scviewer.ui/pom.xml +++ b/plugins/com.minres.scviewer.ui/pom.xml @@ -5,7 +5,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-plugin 1.1.0-SNAPSHOT diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 9c5b89f..0000000 --- a/pom.xml +++ /dev/null @@ -1,152 +0,0 @@ - - 4.0.0 - com.minres.scviewer - com.minres.scviewer.parent - 2.13.2 - pom - - releng/com.minres.scviewer.target - plugins/com.minres.scviewer.database - plugins/com.minres.scviewer.database.sqlite - plugins/com.minres.scviewer.database.text - plugins/com.minres.scviewer.database.vcd - tests/com.minres.scviewer.database.test - plugins/com.minres.scviewer.database.ui.swt - plugins/com.minres.scviewer.e4.application - plugins/com.minres.scviewer.ui - features/com.minres.scviewer.database.feature - features/com.minres.scviewer.ui.feature - features/com.minres.scviewer.feature - features/com.minres.scviewer.e4.platform.feature - features/com.minres.scviewer.e4.feature - releng/com.minres.scviewer.updateSite - products/com.minres.scviewer.e4.product - - - - 1.5.0 - 3.6.0-03 - 3.0.3-01 - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.2.0 - - - parse-version - - parse-version - - - - - - org.eclipse.tycho - tycho-maven-plugin - ${tycho-version} - true - - - org.eclipse.tycho - tycho-versions-plugin - ${tycho-version} - - - - org.eclipse.tycho - target-platform-configuration - ${tycho-version} - - - - com.minres.scviewer - com.minres.scviewer.target - 2.13.2 - - - - - linux - gtk - x86_64 - - - win32 - win32 - x86_64 - - - macosx - cocoa - x86_64 - - - - - - org.eclipse.tycho - tycho-source-plugin - ${tycho-version} - - - - plugin-source - - plugin-source - - - - - - - org.eclipse.tycho.extras - tycho-source-feature-plugin - ${tycho-version} - - - - source-feature - package - - source-feature - - - - - - - - - - - - - - - - - - - org.eclipse.tycho - tycho-p2-plugin - ${tycho-version} - - - attach-p2-metadata - package - - p2-metadata - - - - - - - - diff --git a/products/com.minres.scviewer.e4.product/pom.xml b/products/com.minres.scviewer.e4.product/pom.xml index 004a1e2..a219eaa 100644 --- a/products/com.minres.scviewer.e4.product/pom.xml +++ b/products/com.minres.scviewer.e4.product/pom.xml @@ -7,7 +7,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. com.minres.scviewer.e4.product 2.13.2 diff --git a/releng/com.minres.scviewer.target/pom.xml b/releng/com.minres.scviewer.target/pom.xml index 92536ed..441ac53 100644 --- a/releng/com.minres.scviewer.target/pom.xml +++ b/releng/com.minres.scviewer.target/pom.xml @@ -13,7 +13,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. diff --git a/releng/com.minres.scviewer.updateSite/pom.xml b/releng/com.minres.scviewer.updateSite/pom.xml index a82ee8a..36c84e6 100644 --- a/releng/com.minres.scviewer.updateSite/pom.xml +++ b/releng/com.minres.scviewer.updateSite/pom.xml @@ -8,7 +8,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. @@ -73,4 +73,4 @@ - \ No newline at end of file + diff --git a/tests/com.minres.scviewer.database.test/pom.xml b/tests/com.minres.scviewer.database.test/pom.xml index b8b47cf..41d4269 100644 --- a/tests/com.minres.scviewer.database.test/pom.xml +++ b/tests/com.minres.scviewer.database.test/pom.xml @@ -7,7 +7,7 @@ com.minres.scviewer com.minres.scviewer.parent 2.13.2 - ../.. + ../../.. eclipse-test-plugin