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.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java index 817a6bc..d39ed81 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java @@ -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; 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 94d6b1d..0ee05df 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 @@ -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; 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 3b6ed6f..5872254 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 @@ -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){ diff --git a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java index 9a8732b..b751aa1 100644 --- a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java +++ b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/TrackEntry.java @@ -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 { diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java index 193e432..800fb01 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/Messages.java @@ -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; diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/WaveformPopupMenuContribution.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/WaveformPopupMenuContribution.java index 8550d4d..b4e9228 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/WaveformPopupMenuContribution.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/elements/WaveformPopupMenuContribution.java @@ -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; - } } } } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java index c7f16ea..f7f4111 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/StatusBarControl.java @@ -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); } } }); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties index 67da869..97d2bfd 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties @@ -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 diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java index ecb8cdb..696d955 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/LoadingWaveformDb.java @@ -73,7 +73,7 @@ public class LoadingWaveformDb implements IWaveformDb { } @Override - public boolean load(File inp) throws Exception { + public boolean load(File inp) { return false; } 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 f5673f2..9ca71ef 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 @@ -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 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) diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java index 4a16429..f2ae55c 100644 --- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java +++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/TxEditorPart.java @@ -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; diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/RemoveHandler.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/RemoveHandler.java index 3b3d187..0fd6d77 100644 --- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/RemoveHandler.java +++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/handler/RemoveHandler.java @@ -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); diff --git a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/views/TxOutlinePage.java b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/views/TxOutlinePage.java index 46a8f31..f18ea3c 100644 --- a/com.minres.scviewer.ui/src/com/minres/scviewer/ui/views/TxOutlinePage.java +++ b/com.minres.scviewer.ui/src/com/minres/scviewer/ui/views/TxOutlinePage.java @@ -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()){ diff --git a/com.opcoach.e4.preferences/pom.xml b/com.opcoach.e4.preferences/pom.xml index 5e32d79..4dafa82 100644 --- a/com.opcoach.e4.preferences/pom.xml +++ b/com.opcoach.e4.preferences/pom.xml @@ -4,7 +4,7 @@ com.minres.scviewer com.minres.scviewer.parent - 1.0.0-SNAPSHOT + 2.0.0-SNAPSHOT ../com.minres.scviewer.parent eclipse-plugin