- added preference dialog
- added preference handling - added file monitor to automatically reload changed database
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015 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.swt;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class DatabaseUiPlugin extends Plugin {
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Starting org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
getLog().log(new Status(IStatus.OK, "org.eclipse.e4.core", "Stopping org.eclipse.e4.core bundle..."));
|
||||
}
|
||||
}
|
@ -14,7 +14,10 @@ import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
public class CursorPainter implements IPainter {
|
||||
import com.minres.scviewer.database.ui.ICursor;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class CursorPainter implements IPainter, ICursor {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -58,9 +61,9 @@ public class CursorPainter implements IPainter {
|
||||
long scaleFactor=waveCanvas.getScaleFactor();
|
||||
int x = (int) (time/scaleFactor);
|
||||
int top = id<0?area.y:area.y+15;
|
||||
Color drawColor=waveCanvas.colors[id<0?WaveformCanvas.Colors.CURSOR.ordinal():WaveformCanvas.Colors.MARKER.ordinal()];
|
||||
Color dragColor = waveCanvas.colors[WaveformCanvas.Colors.CURSOR_DRAG.ordinal()];
|
||||
Color textColor=waveCanvas.colors[id<0?WaveformCanvas.Colors.CURSOR_TEXT.ordinal():WaveformCanvas.Colors.MARKER_TEXT.ordinal()];
|
||||
Color drawColor=waveCanvas.colors[id<0?WaveformColors.CURSOR.ordinal():WaveformColors.MARKER.ordinal()];
|
||||
Color dragColor = waveCanvas.colors[WaveformColors.CURSOR_DRAG.ordinal()];
|
||||
Color textColor=waveCanvas.colors[id<0?WaveformColors.CURSOR_TEXT.ordinal():WaveformColors.MARKER_TEXT.ordinal()];
|
||||
if(x>=area.x && x<=(area.x+area.width)){
|
||||
gc.setForeground(isDragging?dragColor:drawColor);
|
||||
gc.drawLine(x, top, x, area.y+area.height);
|
||||
|
@ -20,10 +20,10 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ISignalChangeMulti;
|
||||
import com.minres.scviewer.database.ISignalChangeSingle;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class SignalPainter extends TrackPainter {
|
||||
|
||||
@ -33,7 +33,6 @@ public class SignalPainter extends TrackPainter {
|
||||
private final WaveformCanvas waveCanvas;
|
||||
private ISignal<? extends ISignalChange> signal;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SignalPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = txDisplay;
|
||||
@ -42,9 +41,9 @@ public class SignalPainter extends TrackPainter {
|
||||
|
||||
public void paintArea(GC gc, Rectangle area) {
|
||||
if(trackEntry.selected)
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
else
|
||||
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[even?WaveformColors.TRACK_BG_EVEN.ordinal():WaveformColors.TRACK_BG_ODD.ordinal()]);
|
||||
gc.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
gc.fillRectangle(area);
|
||||
Entry<Long, ? extends ISignalChange> firstChange=signal.getEvents().floorEntry(area.x*this.waveCanvas.getScaleFactor());
|
||||
@ -55,7 +54,7 @@ public class SignalPainter extends TrackPainter {
|
||||
} else if(lastTx==null){
|
||||
lastTx=signal.getEvents().lastEntry();
|
||||
}
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
||||
gc.setLineStyle(SWT.LINE_SOLID);
|
||||
gc.setLineWidth(1);
|
||||
Entry<Long, ? extends ISignalChange> left=firstChange;
|
||||
@ -66,18 +65,18 @@ public class SignalPainter extends TrackPainter {
|
||||
int xBegin= (int)(left.getKey()/this.waveCanvas.getScaleFactor());
|
||||
if(xEnd>xBegin){
|
||||
int yOffset = this.waveCanvas.getTrackHeight()/2;
|
||||
Color color = this.waveCanvas.colors[WaveformCanvas.Colors.SIGNALX.ordinal()];
|
||||
Color color = this.waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
|
||||
switch(((ISignalChangeSingle) left.getValue()).getValue()){
|
||||
case '1':
|
||||
color=this.waveCanvas.colors[WaveformCanvas.Colors.SIGNAL1.ordinal()];
|
||||
color=this.waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()];
|
||||
yOffset = this.waveCanvas.getTrackHeight()/5;
|
||||
break;
|
||||
case '0':
|
||||
color=this.waveCanvas.colors[WaveformCanvas.Colors.SIGNAL0.ordinal()];
|
||||
color=this.waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
|
||||
yOffset = 4*this.waveCanvas.getTrackHeight()/5;
|
||||
break;
|
||||
case 'Z':
|
||||
color=this.waveCanvas.colors[WaveformCanvas.Colors.SIGNALZ.ordinal()];
|
||||
color=this.waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()];
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@ -104,12 +103,12 @@ public class SignalPainter extends TrackPainter {
|
||||
int yOffsetT = this.waveCanvas.getTrackHeight()/5+area.y;
|
||||
int yOffsetM = this.waveCanvas.getTrackHeight()/2+area.y;
|
||||
int yOffsetB = 4*this.waveCanvas.getTrackHeight()/5+area.y;
|
||||
Color colorBorder = this.waveCanvas.colors[WaveformCanvas.Colors.SIGNAL0.ordinal()];
|
||||
Color colorBorder = this.waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
|
||||
ISignalChangeMulti last = (ISignalChangeMulti) left.getValue();
|
||||
if(last.getValue().toString().contains("X")){
|
||||
colorBorder=this.waveCanvas.colors[WaveformCanvas.Colors.SIGNALX.ordinal()];
|
||||
colorBorder=this.waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
|
||||
}else if(last.getValue().toString().contains("Z")){
|
||||
colorBorder=this.waveCanvas.colors[WaveformCanvas.Colors.SIGNALZ.ordinal()];
|
||||
colorBorder=this.waveCanvas.colors[WaveformColors.SIGNALZ.ordinal()];
|
||||
}
|
||||
int beginTime= (int)(left.getKey()/this.waveCanvas.getScaleFactor());
|
||||
int endTime= (int)(right.getKey()/this.waveCanvas.getScaleFactor());
|
||||
@ -123,7 +122,7 @@ public class SignalPainter extends TrackPainter {
|
||||
};
|
||||
gc.setForeground(colorBorder);
|
||||
gc.drawPolygon(points);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.SIGNAL_TEXT.ordinal()]);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformColors.SIGNAL_TEXT.ordinal()]);
|
||||
int size = gc.getDevice().getDPI().y * gc.getFont().getFontData()[0].getHeight()/72;
|
||||
if(beginTime<area.x) beginTime=area.x;
|
||||
int width=endTime-beginTime;
|
||||
|
@ -24,8 +24,8 @@ import org.eclipse.swt.graphics.Rectangle;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class StreamPainter extends TrackPainter{
|
||||
|
||||
@ -35,11 +35,9 @@ public class StreamPainter extends TrackPainter{
|
||||
private final WaveformCanvas waveCanvas;
|
||||
private ITxStream<? extends ITxEvent> stream;
|
||||
private int txBase, txHeight;
|
||||
private int totalHeight;
|
||||
private boolean even;
|
||||
private TreeSet<ITx> seenTx;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
|
||||
super(trackEntry, even);
|
||||
this.waveCanvas = waveCanvas;
|
||||
@ -54,9 +52,9 @@ public class StreamPainter extends TrackPainter{
|
||||
txBase=trackHeight/5;
|
||||
txHeight=trackHeight*3/5;
|
||||
if(trackEntry.selected)
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()]);
|
||||
else
|
||||
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[even?WaveformColors.TRACK_BG_EVEN.ordinal():WaveformColors.TRACK_BG_ODD.ordinal()]);
|
||||
gc.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
gc.fillRectangle(area);
|
||||
Entry<Long, ?> firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor());
|
||||
@ -66,7 +64,7 @@ public class StreamPainter extends TrackPainter{
|
||||
gc.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
gc.setLineStyle(SWT.LINE_SOLID);
|
||||
gc.setLineWidth(1);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
||||
for(int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
|
||||
gc.drawLine(area.x, y1, area.x+area.width, y1);
|
||||
if(firstTx==lastTx)
|
||||
@ -76,8 +74,8 @@ public class StreamPainter extends TrackPainter{
|
||||
seenTx.clear();
|
||||
NavigableMap<Long,?> entries = stream.getEvents().subMap(firstTx.getKey(), true, lastTx.getKey(), true);
|
||||
boolean highlighed=false;
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TX_BG.ordinal()]);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformColors.TX_BG.ordinal()]);
|
||||
for(Entry<Long, ?> entry: entries.entrySet())
|
||||
for(ITxEvent txEvent:(Collection<? extends ITxEvent>)entry.getValue()){
|
||||
if(txEvent.getType()==ITxEvent.Type.BEGIN)
|
||||
@ -93,8 +91,8 @@ public class StreamPainter extends TrackPainter{
|
||||
drawTx(gc, area, tx);
|
||||
}
|
||||
if(highlighed){
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE_HIGHLITE.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TX_BG_HIGHLITE.ordinal()]);
|
||||
gc.setForeground(this.waveCanvas.colors[WaveformColors.LINE_HIGHLITE.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformColors.TX_BG_HIGHLITE.ordinal()]);
|
||||
drawTx(gc, area, waveCanvas.currentSelection);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class TrackAreaPainter implements IPainter {
|
||||
|
||||
/**
|
||||
@ -35,7 +37,7 @@ public class TrackAreaPainter implements IPainter {
|
||||
|
||||
public void paintArea(GC gc, Rectangle a) {
|
||||
Rectangle area = new Rectangle(a.x, a.y+waveCanvas.rulerHeight, a.width, a.height-waveCanvas.rulerHeight);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal()]);
|
||||
gc.setBackground(this.waveCanvas.colors[WaveformColors.TRACK_BG_EVEN.ordinal()]);
|
||||
gc.setFillRule(SWT.FILL_EVEN_ODD);
|
||||
gc.fillRectangle(area);
|
||||
if(trackVerticalOffset.size()>0){
|
||||
|
@ -40,18 +40,11 @@ import com.google.common.collect.Lists;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class WaveformCanvas extends Canvas {
|
||||
public enum Colors {
|
||||
LINE, LINE_HIGHLITE,
|
||||
TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE,
|
||||
TX_BG, TX_BG_HIGHLITE, TX_BORDER,
|
||||
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNAL_TEXT,
|
||||
CURSOR, CURSOR_DRAG, CURSOR_TEXT,
|
||||
MARKER, MARKER_TEXT
|
||||
}
|
||||
|
||||
Color[] colors = new Color[Colors.values().length];
|
||||
|
||||
Color[] colors = new Color[WaveformColors.values().length];
|
||||
|
||||
private int trackHeight = 50;
|
||||
|
||||
@ -134,34 +127,34 @@ public class WaveformCanvas extends Canvas {
|
||||
cursorPainters.add(cursorPainter);
|
||||
}
|
||||
|
||||
private void initColors(HashMap<Colors, RGB> colourMap) {
|
||||
public void initColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
Display d = getDisplay();
|
||||
if (colourMap != null) {
|
||||
for (Colors c : Colors.values()) {
|
||||
for (WaveformColors c : WaveformColors.values()) {
|
||||
if (colourMap.containsKey(c)) {
|
||||
colors[c.ordinal()].dispose();
|
||||
colors[c.ordinal()] = new Color(d, colourMap.get(c));
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
} else {
|
||||
colors[Colors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[Colors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
|
||||
colors[Colors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
|
||||
colors[Colors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
|
||||
colors[Colors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
|
||||
colors[Colors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
|
||||
colors[Colors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[Colors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[Colors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[Colors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[Colors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[Colors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 128, 182);
|
||||
colors[Colors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[Colors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
|
||||
colors[Colors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[Colors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
colors[Colors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
|
||||
colors[Colors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
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_DARK_GREEN);
|
||||
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
|
||||
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
|
||||
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 128, 182);
|
||||
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,7 +267,7 @@ public class WaveformCanvas extends Canvas {
|
||||
*/
|
||||
public void dispose() {
|
||||
transform.dispose();
|
||||
for (Colors c : Colors.values())
|
||||
for (WaveformColors c : WaveformColors.values())
|
||||
colors[c.ordinal()].dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
@ -49,6 +50,7 @@ import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.graphics.TextLayout;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
@ -75,8 +77,10 @@ import com.minres.scviewer.database.ITxStream;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.database.ui.ICursor;
|
||||
import com.minres.scviewer.database.ui.IWaveformViewer;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.WaveformColors;
|
||||
|
||||
public class WaveformViewer implements IWaveformViewer {
|
||||
|
||||
@ -84,8 +88,6 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
|
||||
private PropertyChangeSupport pcs;
|
||||
|
||||
private static final String SELECTION = "selection";
|
||||
|
||||
private ITx currentTxSelection;
|
||||
|
||||
private TrackEntry currentWaveformSelection;
|
||||
@ -120,7 +122,7 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
if ((e.button == 1 || e.button == 3)) {
|
||||
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
|
||||
if (entry != null)
|
||||
setSelection(new StructuredSelection(entry.getValue().waveform));
|
||||
setSelection(new StructuredSelection(entry.getValue()));
|
||||
}
|
||||
if (e.button == 3) {
|
||||
Menu topMenu= top.getMenu();
|
||||
@ -368,11 +370,15 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
if ("size".equals(pce.getPropertyName()) || "content".equals(pce.getPropertyName())) {
|
||||
updateTracklist();
|
||||
waveformCanvas.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateTracklist();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void updateTracklist() {
|
||||
trackVerticalHeight = 0;
|
||||
int nameMaxWidth = 0;
|
||||
@ -556,7 +562,6 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#setSelection(org.eclipse.jface.viewers.ISelection, boolean)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setSelection(ISelection selection, boolean addIfNeeded) {
|
||||
boolean selectionChanged = false;
|
||||
if(currentWaveformSelection!=null) currentWaveformSelection.selected=false;
|
||||
@ -573,9 +578,9 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
if(trackEntry==null && addIfNeeded){
|
||||
trackEntry=new TrackEntry(txSel.getStream());
|
||||
streams.add(trackEntry);
|
||||
currentWaveformSelection = trackEntry;
|
||||
}
|
||||
currentTxSelection = txSel;
|
||||
if(trackEntry!=null) currentWaveformSelection = trackEntry;
|
||||
selectionChanged = true;
|
||||
} else if (sel instanceof TrackEntry && currentWaveformSelection != sel) {
|
||||
currentWaveformSelection = (TrackEntry) sel;
|
||||
@ -615,7 +620,6 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#moveSelection(com.minres.scviewer.database.swt.GotoDirection)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void moveSelection(GotoDirection direction) {
|
||||
if (currentWaveformSelection.isStream()) {
|
||||
ITxStream<? extends ITxEvent> stream = currentWaveformSelection.getStream();
|
||||
@ -875,9 +879,16 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#getActMarkerTime()
|
||||
*/
|
||||
@Override
|
||||
public long getActMarkerTime(){
|
||||
public long getSelectedMarkerTime(){
|
||||
return getMarkerTime(selectedMarker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ICursor> getCursorList(){
|
||||
List<ICursor> cursors = new LinkedList<>();
|
||||
for(CursorPainter painter:waveformCanvas.getCursorPainters()) cursors.add(painter);
|
||||
return Collections.unmodifiableList(cursors);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.swt.IWaveformPanel#getMarkerTime(int)
|
||||
@ -894,12 +905,8 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
if (event.y < trackVerticalHeight) {
|
||||
// event.data =
|
||||
// trackVerticalOffset.floorEntry(event.y).getValue().getFullName();
|
||||
event.doit = true;
|
||||
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(currentWaveformSelection));
|
||||
// System.out.println("dragStart at location "+new
|
||||
// Point(event.x, event.y));
|
||||
}
|
||||
}
|
||||
|
||||
@ -917,7 +924,6 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
dropTarget.setTransfer(types);
|
||||
|
||||
dropTarget.addDropListener(new DropTargetAdapter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void drop(DropTargetEvent event) {
|
||||
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)){
|
||||
ISelection sel = LocalSelectionTransfer.getTransfer().getSelection();
|
||||
@ -926,18 +932,17 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
DropTarget tgt = (DropTarget) event.widget;
|
||||
Point dropPoint = ((Canvas) tgt.getControl()).toControl(event.x, event.y);
|
||||
Object target = trackVerticalOffset.floorEntry(dropPoint.y).getValue();
|
||||
if(source instanceof IWaveform<?> && target instanceof IWaveform<?>){
|
||||
IWaveform<? extends IWaveformEvent> srcWave=(IWaveform<? extends IWaveformEvent>) source;
|
||||
if(source instanceof TrackEntry && target instanceof TrackEntry){
|
||||
TrackEntry srcWave=(TrackEntry) source;
|
||||
int srcIdx=streams.indexOf(srcWave);
|
||||
streams.remove(getEntryForStream((IWaveform<?>)source));
|
||||
streams.remove(srcWave);
|
||||
int tgtIdx=streams.indexOf(target);
|
||||
if(srcIdx<=tgtIdx) tgtIdx++;
|
||||
TrackEntry entry = new TrackEntry(srcWave);
|
||||
if(tgtIdx>=streams.size())
|
||||
streams.add(entry);
|
||||
streams.add(srcWave);
|
||||
else
|
||||
streams.add(tgtIdx, entry);
|
||||
currentWaveformSelection=entry;
|
||||
streams.add(tgtIdx, srcWave);
|
||||
currentWaveformSelection=srcWave;
|
||||
updateTracklist();
|
||||
} else if(source instanceof CursorPainter){
|
||||
((CursorPainter)source).setTime(0);
|
||||
@ -969,7 +974,6 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
dragSource.setTransfer(types);
|
||||
dragSource.addDragListener(new DragSourceAdapter() {
|
||||
public void dragStart(DragSourceEvent event) {
|
||||
System.out.println("dragStart");
|
||||
event.doit = false;
|
||||
List<Object> clicked = waveformCanvas.getClicked(new Point(event.x, event.y));
|
||||
for(Object o:clicked){
|
||||
@ -1115,4 +1119,9 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColors(HashMap<WaveformColors, RGB> colourMap) {
|
||||
waveformCanvas.initColors(colourMap);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user