From 60185fbaeefa25de2d55651f1c8e66d9d3bbe0f3 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Oct 2018 10:03:04 +0200 Subject: [PATCH 1/3] Version inconsitency fixes --- com.minres.scviewer.database.sqlite/pom.xml | 3 ++- com.minres.scviewer.database.test/pom.xml | 3 ++- com.minres.scviewer.database/pom.xml | 3 ++- .../src/com/minres/scviewer/e4/application/E4LifeCycle.java | 2 +- com.minres.scviewer.feature/pom.xml | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/com.minres.scviewer.database.sqlite/pom.xml b/com.minres.scviewer.database.sqlite/pom.xml index e7c3d17..116c43e 100644 --- a/com.minres.scviewer.database.sqlite/pom.xml +++ b/com.minres.scviewer.database.sqlite/pom.xml @@ -15,4 +15,5 @@ 3.8.7 - \ No newline at end of file + 1.0.0-SNAPSHOT + \ No newline at end of file diff --git a/com.minres.scviewer.database.test/pom.xml b/com.minres.scviewer.database.test/pom.xml index 977912e..789f91b 100644 --- a/com.minres.scviewer.database.test/pom.xml +++ b/com.minres.scviewer.database.test/pom.xml @@ -27,4 +27,5 @@ - \ No newline at end of file + 1.0.0-SNAPSHOT + \ No newline at end of file diff --git a/com.minres.scviewer.database/pom.xml b/com.minres.scviewer.database/pom.xml index b91d796..4fc670b 100644 --- a/com.minres.scviewer.database/pom.xml +++ b/com.minres.scviewer.database/pom.xml @@ -8,4 +8,5 @@ ../com.minres.scviewer.parent eclipse-plugin - \ No newline at end of file + 1.0.0-SNAPSHOT + \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java index 2b4e79f..3866bed 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java @@ -64,7 +64,7 @@ public class E4LifeCycle { @PostContextCreate void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) { final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS); - Options opt = new Options(args, 0); + Options opt = new Options(args, 0, 1); opt.getSet() .addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE) .addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE); diff --git a/com.minres.scviewer.feature/pom.xml b/com.minres.scviewer.feature/pom.xml index 323a625..8da4db3 100644 --- a/com.minres.scviewer.feature/pom.xml +++ b/com.minres.scviewer.feature/pom.xml @@ -8,4 +8,5 @@ 2.0.0-SNAPSHOT ../com.minres.scviewer.parent - \ No newline at end of file + 1.0.0-SNAPSHOT + \ No newline at end of file From 97a806f9d98a2601064db48f6cd21af8da6a97a2 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Oct 2018 21:55:35 +0200 Subject: [PATCH 2/3] Changed selection handling and fixed keycode handling --- .../database/swt/internal/WaveformCanvas.java | 33 ++++++---- .../database/swt/internal/WaveformViewer.java | 27 +++----- .../e4/application/parts/WaveformViewer.java | 64 +++++++++++-------- 3 files changed, 68 insertions(+), 56 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java index 2845258..3e4bfc5 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java @@ -287,9 +287,13 @@ public class WaveformCanvas extends Canvas { } public void clearAllWaveformPainter() { + clearAllWaveformPainter(true); + } + + void clearAllWaveformPainter(boolean update) { trackAreaPainter.getTrackVerticalOffset().clear(); wave2painterMap.clear(); - syncScrollBars(); + if(update) syncScrollBars(); } public void addWaveformPainter(IWaveformPainter painter) { @@ -350,38 +354,41 @@ public class WaveformCanvas extends Canvas { redraw(); return; } - int height = trackAreaPainter.getHeight(); + int height = trackAreaPainter.getHeight(); // incl. Ruler int width = (int) (maxTime / scaleFactor); + Rectangle clientArea=getClientArea(); ScrollBar horizontal = getHorizontalBar(); horizontal.setIncrement((int) (getClientArea().width / 100)); horizontal.setPageIncrement(getClientArea().width); - int cw = getClientArea().width; - if (width > cw) { /* image is wider than client area */ + int clientWidthw = clientArea.width; + if (width > clientWidthw) { /* image is wider than client area */ + horizontal.setMinimum(0); horizontal.setMaximum(width); horizontal.setEnabled(true); - if (((int) -origin.x) > horizontal.getMaximum() - cw) - origin.x = -horizontal.getMaximum() + cw; + if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw) + origin.x = -horizontal.getMaximum() + clientWidthw; } else { /* image is narrower than client area */ horizontal.setEnabled(false); } + horizontal.setThumb(clientWidthw); horizontal.setSelection(-origin.x); - horizontal.setThumb(cw); ScrollBar vertical = getVerticalBar(); vertical.setIncrement((int) (getClientArea().height / 100)); vertical.setPageIncrement((int) (getClientArea().height)); - int ch = getClientArea().height; - if (height > ch) { /* image is higher than client area */ + int clientHeighth = clientArea.height; + if (height > clientHeighth) { /* image is higher than client area */ + vertical.setMinimum(0); vertical.setMaximum(height); vertical.setEnabled(true); - if (((int) -origin.y) > vertical.getMaximum() - ch) - origin.y = -vertical.getMaximum() + ch; + if (((int) -origin.y) > vertical.getMaximum() - clientHeighth) + origin.y = -vertical.getMaximum() + clientHeighth; } else { /* image is less higher than client area */ - vertical.setMaximum((int) (ch)); + vertical.setMaximum((int) (clientHeighth)); vertical.setEnabled(false); } + vertical.setThumb(clientHeighth); vertical.setSelection(-origin.y); - vertical.setThumb(ch); redraw(); fireSelectionEvent(); diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index 6444558..a6ccb23 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -219,7 +219,7 @@ public class WaveformViewer implements IWaveformViewer { nameFontB = SWTResourceManager.getBoldFont(nameFont); streams = new ObservableList<>(); - streams.addPropertyChangeListener(this); + streams.addPropertyChangeListener("content", this); top = new Composite(parent, SWT.NONE); top.setLayout(new FillLayout(SWT.HORIZONTAL)); @@ -381,22 +381,21 @@ public class WaveformViewer implements IWaveformViewer { }); revealSelected=false; } else - waveformCanvas.getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - update(); - } - }); + waveformCanvas.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + update(); + } + }); } } public void update() { trackVerticalHeight = 0; int nameMaxWidth = 0; - int previousHeight = trackVerticalOffset.size() == 0 ? 0 : trackVerticalOffset.lastKey(); IWaveformPainter painter = null; trackVerticalOffset.clear(); - waveformCanvas.clearAllWaveformPainter(); + waveformCanvas.clearAllWaveformPainter(false); boolean even = true; boolean clearSelection = true; TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); @@ -431,16 +430,8 @@ public class WaveformViewer implements IWaveformViewer { top.layout(new Control[] { valueList, nameList, waveformCanvas }); if (trackVerticalOffset.isEmpty()){ waveformCanvas.setOrigin(0, 0); - }else if(previousHeight > trackVerticalOffset.lastKey()){ - Point o = waveformCanvas.getOrigin(); - waveformCanvas.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey())); } if(clearSelection) setSelection(new StructuredSelection()); - /* System.out.println("updateTracklist() state:"); - for(Entry> entry: trackVerticalOffset.entrySet()){ - System.out.println(" "+entry.getKey()+": " +entry.getValue().getFullName()); - } - */ } private int calculateValueWidth() { @@ -629,7 +620,7 @@ public class WaveformViewer implements IWaveformViewer { } if(currentWaveformSelection!=null) currentWaveformSelection.selected=true; if (selectionChanged) { - waveformCanvas.reveal(currentWaveformSelection.waveform); + if(currentWaveformSelection!=null) waveformCanvas.reveal(currentWaveformSelection.waveform); waveformCanvas.setSelected(currentTxSelection); valueList.redraw(); nameList.redraw(); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 06cb2d3..5674cba 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -19,6 +19,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -57,6 +58,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; @@ -282,30 +284,18 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis @Override public void handleEvent(Event e) { - int state = e.stateMask & SWT.MODIFIER_MASK; - if(Platform.OS_MACOSX.equals(Platform.getOS())) { //swap cammnd and control for MacOSX - if((state&SWT.COMMAND)!=0) { - state&=~SWT.COMMAND; - state|=SWT.CONTROL; - } else if((state&SWT.CONTROL)!=0) { - state&=~SWT.CONTROL; - state|=SWT.COMMAND; + if(e==null) { // dummy to take out logging + String string = e.type == SWT.KeyDown ? "DOWN:" : "UP :"; + string += " stateMask=0x" + Integer.toHexString (e.stateMask) + ","; // SWT.CTRL, SWT.ALT, SWT.SHIFT, SWT.COMMAND + string += " keyCode=0x" + Integer.toHexString (e.keyCode) + ","; + string += " character=0x" + Integer.toHexString (e.character) ; + if (e.keyLocation != 0) { + string += " location="+e.keyLocation; } + System.out.println (string); } - if(state==SWT.ALT) { - switch(e.keyCode) { - case SWT.ARROW_LEFT: - waveformPane.scrollHorizontal(-100); - return; - case SWT.ARROW_RIGHT: - waveformPane.scrollHorizontal(100); - return; - case SWT.KEYPAD_ADD: - return; - case SWT.KEYPAD_SUBTRACT: - return; - } - } else if(state==SWT.CTRL) { + if((e.stateMask&SWT.MOD3)!=0) { // Alt key + } else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd int zoomlevel = waveformPane.getZoomLevel(); switch(e.keyCode) { case '+': @@ -325,7 +315,15 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.moveSelectedTrack(1); return; } - } else if(state==SWT.SHIFT) { + } else if((e.stateMask&SWT.MOD2)!=0) { //Shift + switch(e.keyCode) { + case SWT.ARROW_LEFT: + waveformPane.scrollHorizontal(-100); + return; + case SWT.ARROW_RIGHT: + waveformPane.scrollHorizontal(100); + return; + } } else { switch(e.keyCode) { case SWT.ARROW_LEFT: @@ -344,7 +342,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis case SWT.END: return; //TODO: should be handled } } - } }); @@ -800,7 +797,24 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis */ public void removeStreamFromList(IWaveform stream) { TrackEntry trackEntry = waveformPane.getEntryForStream(stream); - waveformPane.getStreamList().remove(trackEntry); + List streams = waveformPane.getStreamList(); + ISelection sel = waveformPane.getSelection(); + TrackEntry newSelection=null; + if(sel instanceof IStructuredSelection && ((IStructuredSelection) sel).size()==2) { + Iterator it = ((IStructuredSelection)sel).iterator(); + it.next(); + int idx = streams.indexOf(it.next()); + if(idx==streams.size()-1) + newSelection=streams.get(idx-1); + else + newSelection=streams.get(idx+1); + } + waveformPane.setSelection(new StructuredSelection()); + streams.remove(trackEntry); + if(newSelection!=null) { + Object[] o = {newSelection}; + waveformPane.setSelection(new StructuredSelection(o)); + } } /** From 42660c7a2e4e8cf4e12b7fb09e64abdf12575859 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 15 Oct 2018 22:01:44 +0200 Subject: [PATCH 3/3] Fixed some warnings --- com.minres.scviewer.database.ui.swt/pom.xml | 1 - com.minres.scviewer.database.vcd/pom.xml | 1 - .../minres/scviewer/e4/application/parts/WaveformViewer.java | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/pom.xml b/com.minres.scviewer.database.ui.swt/pom.xml index de49454..8079c8c 100644 --- a/com.minres.scviewer.database.ui.swt/pom.xml +++ b/com.minres.scviewer.database.ui.swt/pom.xml @@ -1,7 +1,6 @@ 4.0.0 com.minres.scviewer.database.ui.swt - 2.0.0-SNAPSHOT eclipse-plugin com.minres.scviewer diff --git a/com.minres.scviewer.database.vcd/pom.xml b/com.minres.scviewer.database.vcd/pom.xml index f1a21ec..20be6aa 100644 --- a/com.minres.scviewer.database.vcd/pom.xml +++ b/com.minres.scviewer.database.vcd/pom.xml @@ -8,5 +8,4 @@ ../com.minres.scviewer.parent eclipse-plugin - 2.0.0-SNAPSHOT \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 5674cba..b5eaf08 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -33,7 +33,6 @@ import javax.inject.Named; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.IJobChangeEvent; @@ -282,6 +281,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.getWaveformControl().addListener(SWT.KeyDown, new Listener() { + @SuppressWarnings("null") @Override public void handleEvent(Event e) { if(e==null) { // dummy to take out logging