Merge branch 'release/2.0.1'

This commit is contained in:
Eyck Jentzsch 2018-10-15 22:30:02 +02:00
commit 9f902057ba
10 changed files with 78 additions and 64 deletions

View File

@ -15,4 +15,5 @@
<version>3.8.7</version> <version>3.8.7</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -27,4 +27,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -1,7 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.database.ui.swt</artifactId> <artifactId>com.minres.scviewer.database.ui.swt</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<parent> <parent>
<groupId>com.minres.scviewer</groupId> <groupId>com.minres.scviewer</groupId>

View File

@ -287,9 +287,13 @@ public class WaveformCanvas extends Canvas {
} }
public void clearAllWaveformPainter() { public void clearAllWaveformPainter() {
clearAllWaveformPainter(true);
}
void clearAllWaveformPainter(boolean update) {
trackAreaPainter.getTrackVerticalOffset().clear(); trackAreaPainter.getTrackVerticalOffset().clear();
wave2painterMap.clear(); wave2painterMap.clear();
syncScrollBars(); if(update) syncScrollBars();
} }
public void addWaveformPainter(IWaveformPainter painter) { public void addWaveformPainter(IWaveformPainter painter) {
@ -350,38 +354,41 @@ public class WaveformCanvas extends Canvas {
redraw(); redraw();
return; return;
} }
int height = trackAreaPainter.getHeight(); int height = trackAreaPainter.getHeight(); // incl. Ruler
int width = (int) (maxTime / scaleFactor); int width = (int) (maxTime / scaleFactor);
Rectangle clientArea=getClientArea();
ScrollBar horizontal = getHorizontalBar(); ScrollBar horizontal = getHorizontalBar();
horizontal.setIncrement((int) (getClientArea().width / 100)); horizontal.setIncrement((int) (getClientArea().width / 100));
horizontal.setPageIncrement(getClientArea().width); horizontal.setPageIncrement(getClientArea().width);
int cw = getClientArea().width; int clientWidthw = clientArea.width;
if (width > cw) { /* image is wider than client area */ if (width > clientWidthw) { /* image is wider than client area */
horizontal.setMinimum(0);
horizontal.setMaximum(width); horizontal.setMaximum(width);
horizontal.setEnabled(true); horizontal.setEnabled(true);
if (((int) -origin.x) > horizontal.getMaximum() - cw) if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw)
origin.x = -horizontal.getMaximum() + cw; origin.x = -horizontal.getMaximum() + clientWidthw;
} else { /* image is narrower than client area */ } else { /* image is narrower than client area */
horizontal.setEnabled(false); horizontal.setEnabled(false);
} }
horizontal.setThumb(clientWidthw);
horizontal.setSelection(-origin.x); horizontal.setSelection(-origin.x);
horizontal.setThumb(cw);
ScrollBar vertical = getVerticalBar(); ScrollBar vertical = getVerticalBar();
vertical.setIncrement((int) (getClientArea().height / 100)); vertical.setIncrement((int) (getClientArea().height / 100));
vertical.setPageIncrement((int) (getClientArea().height)); vertical.setPageIncrement((int) (getClientArea().height));
int ch = getClientArea().height; int clientHeighth = clientArea.height;
if (height > ch) { /* image is higher than client area */ if (height > clientHeighth) { /* image is higher than client area */
vertical.setMinimum(0);
vertical.setMaximum(height); vertical.setMaximum(height);
vertical.setEnabled(true); vertical.setEnabled(true);
if (((int) -origin.y) > vertical.getMaximum() - ch) if (((int) -origin.y) > vertical.getMaximum() - clientHeighth)
origin.y = -vertical.getMaximum() + ch; origin.y = -vertical.getMaximum() + clientHeighth;
} else { /* image is less higher than client area */ } else { /* image is less higher than client area */
vertical.setMaximum((int) (ch)); vertical.setMaximum((int) (clientHeighth));
vertical.setEnabled(false); vertical.setEnabled(false);
} }
vertical.setThumb(clientHeighth);
vertical.setSelection(-origin.y); vertical.setSelection(-origin.y);
vertical.setThumb(ch);
redraw(); redraw();
fireSelectionEvent(); fireSelectionEvent();

View File

@ -219,7 +219,7 @@ public class WaveformViewer implements IWaveformViewer {
nameFontB = SWTResourceManager.getBoldFont(nameFont); nameFontB = SWTResourceManager.getBoldFont(nameFont);
streams = new ObservableList<>(); streams = new ObservableList<>();
streams.addPropertyChangeListener(this); streams.addPropertyChangeListener("content", this);
top = new Composite(parent, SWT.NONE); top = new Composite(parent, SWT.NONE);
top.setLayout(new FillLayout(SWT.HORIZONTAL)); top.setLayout(new FillLayout(SWT.HORIZONTAL));
@ -381,22 +381,21 @@ public class WaveformViewer implements IWaveformViewer {
}); });
revealSelected=false; revealSelected=false;
} else } else
waveformCanvas.getDisplay().asyncExec(new Runnable() { waveformCanvas.getDisplay().asyncExec(new Runnable() {
@Override @Override
public void run() { public void run() {
update(); update();
} }
}); });
} }
} }
public void update() { public void update() {
trackVerticalHeight = 0; trackVerticalHeight = 0;
int nameMaxWidth = 0; int nameMaxWidth = 0;
int previousHeight = trackVerticalOffset.size() == 0 ? 0 : trackVerticalOffset.lastKey();
IWaveformPainter painter = null; IWaveformPainter painter = null;
trackVerticalOffset.clear(); trackVerticalOffset.clear();
waveformCanvas.clearAllWaveformPainter(); waveformCanvas.clearAllWaveformPainter(false);
boolean even = true; boolean even = true;
boolean clearSelection = true; boolean clearSelection = true;
TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
@ -431,16 +430,8 @@ public class WaveformViewer implements IWaveformViewer {
top.layout(new Control[] { valueList, nameList, waveformCanvas }); top.layout(new Control[] { valueList, nameList, waveformCanvas });
if (trackVerticalOffset.isEmpty()){ if (trackVerticalOffset.isEmpty()){
waveformCanvas.setOrigin(0, 0); 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()); if(clearSelection) setSelection(new StructuredSelection());
/* System.out.println("updateTracklist() state:");
for(Entry<Integer, IWaveform<? extends IWaveformEvent>> entry: trackVerticalOffset.entrySet()){
System.out.println(" "+entry.getKey()+": " +entry.getValue().getFullName());
}
*/
} }
private int calculateValueWidth() { private int calculateValueWidth() {
@ -629,7 +620,7 @@ public class WaveformViewer implements IWaveformViewer {
} }
if(currentWaveformSelection!=null) currentWaveformSelection.selected=true; if(currentWaveformSelection!=null) currentWaveformSelection.selected=true;
if (selectionChanged) { if (selectionChanged) {
waveformCanvas.reveal(currentWaveformSelection.waveform); if(currentWaveformSelection!=null) waveformCanvas.reveal(currentWaveformSelection.waveform);
waveformCanvas.setSelected(currentTxSelection); waveformCanvas.setSelected(currentTxSelection);
valueList.redraw(); valueList.redraw();
nameList.redraw(); nameList.redraw();

View File

@ -8,5 +8,4 @@
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<version>2.0.0-SNAPSHOT</version>
</project> </project>

View File

@ -8,4 +8,5 @@
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> <version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -64,7 +64,7 @@ public class E4LifeCycle {
@PostContextCreate @PostContextCreate
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) { void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) {
final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS); 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() opt.getSet()
.addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE) .addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE)
.addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE); .addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE);

View File

@ -19,6 +19,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -32,7 +33,6 @@ import javax.inject.Named;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeEvent;
@ -57,6 +57,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.MouseTrackListener;
@ -280,32 +281,21 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
waveformPane.getWaveformControl().addListener(SWT.KeyDown, new Listener() { waveformPane.getWaveformControl().addListener(SWT.KeyDown, new Listener() {
@SuppressWarnings("null")
@Override @Override
public void handleEvent(Event e) { public void handleEvent(Event e) {
int state = e.stateMask & SWT.MODIFIER_MASK; if(e==null) { // dummy to take out logging
if(Platform.OS_MACOSX.equals(Platform.getOS())) { //swap cammnd and control for MacOSX String string = e.type == SWT.KeyDown ? "DOWN:" : "UP :";
if((state&SWT.COMMAND)!=0) { string += " stateMask=0x" + Integer.toHexString (e.stateMask) + ","; // SWT.CTRL, SWT.ALT, SWT.SHIFT, SWT.COMMAND
state&=~SWT.COMMAND; string += " keyCode=0x" + Integer.toHexString (e.keyCode) + ",";
state|=SWT.CONTROL; string += " character=0x" + Integer.toHexString (e.character) ;
} else if((state&SWT.CONTROL)!=0) { if (e.keyLocation != 0) {
state&=~SWT.CONTROL; string += " location="+e.keyLocation;
state|=SWT.COMMAND;
} }
System.out.println (string);
} }
if(state==SWT.ALT) { if((e.stateMask&SWT.MOD3)!=0) { // Alt key
switch(e.keyCode) { } else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd
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) {
int zoomlevel = waveformPane.getZoomLevel(); int zoomlevel = waveformPane.getZoomLevel();
switch(e.keyCode) { switch(e.keyCode) {
case '+': case '+':
@ -325,7 +315,15 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
waveformPane.moveSelectedTrack(1); waveformPane.moveSelectedTrack(1);
return; 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 { } else {
switch(e.keyCode) { switch(e.keyCode) {
case SWT.ARROW_LEFT: case SWT.ARROW_LEFT:
@ -344,7 +342,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
case SWT.END: return; //TODO: should be handled case SWT.END: return; //TODO: should be handled
} }
} }
} }
}); });
@ -800,7 +797,24 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/ */
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> stream) { public void removeStreamFromList(IWaveform<? extends IWaveformEvent> stream) {
TrackEntry trackEntry = waveformPane.getEntryForStream(stream); TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
waveformPane.getStreamList().remove(trackEntry); List<TrackEntry> 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));
}
} }
/** /**

View File

@ -8,4 +8,5 @@
<version>2.0.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
</project> <version>1.0.0-SNAPSHOT</version>
</project>