Updated UI to reflect database changes esp. in VCD

This commit is contained in:
Eyck Jentzsch 2018-11-06 08:26:39 +01:00
parent 47a285bf6d
commit f81e830e93
15 changed files with 87 additions and 112 deletions

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">
<modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.database.ui.swt</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>com.minres.scviewer</groupId>

View File

@ -182,7 +182,6 @@ public class SignalPainter extends TrackPainter {
tmpAwtFont = new java.awt.Font(fd.getName(), fd.getStyle(), height);
}
@SuppressWarnings("unchecked")
public void draw(GC gc, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
BitVector last = (BitVector) left;
@ -267,7 +266,6 @@ public class SignalPainter extends TrackPainter {
}
@SuppressWarnings("unchecked")
public void draw(GC gc, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
long leftVal = ((BitVector) left).toUnsignedValue();
long rightVal= ((BitVector) right).toUnsignedValue();
@ -294,7 +292,6 @@ public class SignalPainter extends TrackPainter {
}
private class SingleBitStencil implements SignalStencil {
@SuppressWarnings("unchecked")
public void draw(GC gc, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
if (multiple) {
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]);
@ -375,7 +372,6 @@ public class SignalPainter extends TrackPainter {
}
}
@SuppressWarnings("unchecked")
public void draw(GC gc, Rectangle area, Object left, Object right, int xBegin, int xEnd, boolean multiple) {
double leftVal = (Double) left;
double rightVal= (Double) right;

View File

@ -39,7 +39,6 @@ import org.eclipse.wb.swt.SWTResourceManager;
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.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.ui.IWaveformViewer;

View File

@ -14,7 +14,6 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@ -79,7 +78,6 @@ import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.ui.GotoDirection;
@ -423,8 +421,6 @@ public class WaveformViewer implements IWaveformViewer {
waveformCanvas.syncScrollBars();
nameList.setSize(nameMaxWidth + 15, trackVerticalHeight);
nameListScrolled.setMinSize(nameMaxWidth + 15, trackVerticalHeight);
valueList.setSize(calculateValueWidth(), trackVerticalHeight);
valueListScrolled.setMinSize(calculateValueWidth(), trackVerticalHeight);
nameList.redraw();
updateValueList();
waveformCanvas.redraw();
@ -501,7 +497,10 @@ public class WaveformViewer implements IWaveformViewer {
}
}
}
valueList.redraw();
int width = calculateValueWidth();
valueList.setSize(width, trackVerticalHeight);
valueListScrolled.setMinSize(width, trackVerticalHeight);
valueListScrolled.redraw();
}
private boolean isArrayFull(Object[] array){

View File

@ -14,7 +14,6 @@ import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
public class TrackEntry {

View File

@ -40,6 +40,8 @@ public class Messages extends NLS {
public static String TransactionDetails_3;
public static String TransactionDetails_4;
public static String WaveformPreferencesPage_1;
public static String WaveformViewer_13;
public static String WaveformViewer_14;
public static String WaveformViewer_15;
public static String WaveformViewer_16;
public static String WaveformViewer_17;

View File

@ -44,9 +44,10 @@ public class WaveformPopupMenuContribution {
Object selected = ((IStructuredSelection)sel).getFirstElement();
if(selected instanceof ISignal<?>) {
Object x = ((ISignal<?>) selected).getEvents().firstEntry().getValue();
if((x instanceof Double) || (x instanceof BitVector)) {
if((x instanceof BitVector) && ((BitVector)x).getWidth()==1) {
return false;
} else
return true;
}
}
}
}

View File

@ -186,17 +186,15 @@ public class StatusBarControl {
*/
@Override
public void beginTask(final String name, final int totalWork) {
sync.syncExec(new Runnable() {
sync.asyncExec(new Runnable() {
@Override
public void run() {
if(runningTasks <= 0) { // --- no task is running at the moment ---
progressBar.setEnabled(false);
progressBar.setSelection(0);
progressBar.setMaximum(totalWork);
} else { // --- other tasks are running ---
progressBar.setMaximum(progressBar.getMaximum() + totalWork);
}
runningTasks++;
if(runningTasks == 1) { // --- no task is running at the moment ---
progressBar.setEnabled(true);
progressBar.setSelection(0);
}
progressBar.setMaximum(totalWork);
progressBar.setToolTipText(Messages.StatusBarControl_1 + runningTasks + Messages.StatusBarControl_2 + name);
}
});
@ -207,7 +205,7 @@ public class StatusBarControl {
*/
@Override
public void worked(final int work) {
sync.syncExec(new Runnable() {
sync.asyncExec(new Runnable() {
@Override
public void run() {
progressBar.setSelection(progressBar.getSelection() + work);
@ -215,63 +213,28 @@ public class StatusBarControl {
});
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.NullProgressMonitor#done()
/**
* Adds the job.
*
* @param job the job
* @return the i progress monitor
*/
@Override
public void done() {
sync.syncExec(new Runnable() {
@Override
public void run() {
progressBar.setSelection(0);
progressBar.setMaximum(1);
progressBar.setEnabled(false);
}
});
}
/**
* Adds the job.
*
* @param job the job
* @return the i progress monitor
*/
/*
@Override
public boolean isCanceled() {
sync.syncExec(new Runnable() {
@Override
public void run() {
cancelled=delegate.isCanceled();
}
});
return cancelled;
}
@Override
public void setCanceled(final boolean value) {
sync.syncExec(new Runnable() {
@Override
public void run() {
delegate.setCanceled(value);
}
});
}
*/
public IProgressMonitor addJob(Job job){
if(job != null){
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
sync.syncExec(new Runnable() {
public void done(final IJobChangeEvent event) {
sync.asyncExec(new Runnable() {
@Override
public void run() {
runningTasks--;
if(event.getResult()==null) return;
if(runningTasks>0) runningTasks--;
if (runningTasks > 0){ // --- some tasks are still running ---
progressBar.setToolTipText(Messages.StatusBarControl_3 + runningTasks);
} else { // --- all tasks are done (a reset of selection could also be done) ---
progressBar.setToolTipText(Messages.StatusBarControl_4);
progressBar.setSelection(progressBar.getMaximum());
progressBar.setEnabled(false);
}
}
});

View File

@ -34,6 +34,8 @@ TransactionDetails_21=End time
TransactionDetails_3=Value
TransactionDetails_4=Relation
WaveformPreferencesPage_1=Color for
WaveformViewer_13=Database Load Status
WaveformViewer_14=Database Load Cancelled
WaveformViewer_15=Database Load Job
WaveformViewer_16=Loading
WaveformViewer_17=Database re-load

View File

@ -73,7 +73,7 @@ public class LoadingWaveformDb implements IWaveformDb {
}
@Override
public boolean load(File inp) throws Exception {
public boolean load(File inp) {
return false;
}

View File

@ -31,14 +31,19 @@ import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.core.internal.jobs.JobManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.core.runtime.jobs.JobGroup;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
@ -48,6 +53,7 @@ import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.PersistState;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
@ -75,7 +81,6 @@ import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.swt.WaveformViewerFactory;
@ -143,6 +148,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
/** The waveform pane. */
private IWaveformViewer waveformPane;
/** get UISynchronize injected as field */
@Inject UISynchronize sync;
/** The event broker. */
@Inject
private IEventBroker eventBroker;
@ -284,7 +292,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
@Override
public void handleEvent(Event e) {
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) + ",";
@ -293,7 +301,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
string += " location="+e.keyLocation;
}
System.out.println (string);
}
*/
if((e.stateMask&SWT.MOD3)!=0) { // Alt key
} else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd
int zoomlevel = waveformPane.getZoomLevel();
@ -411,7 +419,23 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
}
waveformPane.setColors(colorPref);
}
class DbLoadJob extends Job {
final File file;
public DbLoadJob(String name, final File file) {
super(name);
this.file=file;
}
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.setTaskName(Messages.WaveformViewer_16+file.getName());
boolean res = database.load(file);
monitor.done();
database.addPropertyChangeListener(waveformPane);
return res?Status.OK_STATUS:Status.CANCEL_STATUS;
}
}
/**
* Load database.
*
@ -419,50 +443,46 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/
protected void loadDatabase(final Map<String, String> state) {
fileMonitor.removeFileChangeListener(this);
MultiStatus fStatus= new MultiStatus("blah", IStatus.OK, Messages.WaveformViewer_13, null);
Job job = new Job(Messages.WaveformViewer_15) {
@Override
protected IStatus run(IProgressMonitor monitor) {
// convert to SubMonitor and set total number of work units
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()+1);
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size());
JobGroup jobGroup = new JobGroup(Messages.WaveformViewer_15, filesToLoad.size(), filesToLoad.size());
filesToLoad.forEach((final File file) -> {
Job job = new DbLoadJob(Messages.WaveformViewer_16 + file.getName(), file);
job.setProgressGroup(subMonitor, 1);
job.setJobGroup(jobGroup);
job.schedule();
});
try {
subMonitor.worked(1);
for (File file : filesToLoad) {
subMonitor.setTaskName(Messages.WaveformViewer_16+file.getName());
database.load(file);
database.addPropertyChangeListener(waveformPane);
subMonitor.worked(1);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
}
} catch (Exception e) {
database = null;
e.printStackTrace();
return Status.CANCEL_STATUS;
jobGroup.join(0, monitor);
} catch (OperationCanceledException | InterruptedException e) {
throw new OperationCanceledException(Messages.WaveformViewer_14);
}
subMonitor.done();
monitor.done();
return Status.OK_STATUS;
if (monitor.isCanceled())
throw new OperationCanceledException(Messages.WaveformViewer_14);
fStatus.addAll(jobGroup.getResult());
return fStatus;
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult() == Status.OK_STATUS)
myParent.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
waveformPane.setMaxTime(database.getMaxTime());
if (state != null)
restoreWaveformViewerState(state);
fileChecker = null;
if (checkForUpdates)
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad,
FILE_CHECK_INTERVAL);
}
});
if (event.getResult().getCode() != Status.OK_STATUS.getCode()) return;
sync.asyncExec(()->{
waveformPane.setMaxTime(database.getMaxTime());
if (state != null)
restoreWaveformViewerState(state);
fileChecker = null;
if (checkForUpdates)
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL);
});
}
});
job.schedule(0);
job.setSystem(true);
job.schedule(1000L); // let the UI initialize so that we have a progress monitor
}
/* (non-Javadoc)

View File

@ -48,7 +48,6 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.swt.WaveformViewerFactory;
import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.IWaveformViewer;

View File

@ -19,12 +19,10 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.ui.TxEditorPart;
public class RemoveHandler extends AbstractHandler {
@SuppressWarnings("unchecked")
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);

View File

@ -36,7 +36,6 @@ import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import com.minres.scviewer.database.IHierNode;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.ui.TxEditorPart;
import com.minres.scviewer.ui.views.provider.TxDbTreeContentProvider;
import com.minres.scviewer.ui.views.provider.TxDbTreeLabelProvider;
@ -177,7 +176,6 @@ public class TxOutlinePage extends ContentOutlinePage implements ISelectionList
private Action makeStreamAction(String text, String imgDescriptor, final IStructuredSelection selection, boolean enabled, final boolean remove) {
Action action = new Action() {
@SuppressWarnings("unchecked")
public void run() {
if(selection!=null)
for(Object obj :selection.toArray()){

View File

@ -4,7 +4,7 @@
<parent>
<groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../com.minres.scviewer.parent</relativePath>
</parent>
<packaging>eclipse-plugin</packaging>