update status bar handling

This commit is contained in:
Eyck Jentzsch 2020-06-14 21:59:42 +02:00
parent ab2146102f
commit 230e8dcc7a
8 changed files with 397 additions and 175 deletions

View File

@ -54,9 +54,12 @@
</features> </features>
<configurations> <configurations>
<plugin id="com.minres.scviewer.database.text" autoStart="true" startLevel="2" />
<plugin id="com.minres.scviewer.database.vcd" autoStart="true" startLevel="2" />
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="1" /> <plugin id="org.apache.felix.scr" autoStart="true" startLevel="1" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" /> <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" /> <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" /> <plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
<plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" /> <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" />
</configurations> </configurations>

View File

@ -3,9 +3,13 @@
<feature url="features/com.minres.scviewer.feature_1.0.0.qualifier.jar" id="com.minres.scviewer.feature" version="1.0.0.qualifier"> <feature url="features/com.minres.scviewer.feature_1.0.0.qualifier.jar" id="com.minres.scviewer.feature" version="1.0.0.qualifier">
<category name="com.minres.scviewer"/> <category name="com.minres.scviewer"/>
</feature> </feature>
<feature id="com.minres.scviewer.e4.feature">
<category name="com.minres.scviewer.e4"/>
</feature>
<category-def name="com.minres.scviewer" label="SCViewer"> <category-def name="com.minres.scviewer" label="SCViewer">
<description> <description>
Viewer for SystemC Verification (SCV) library&apos;s transaction recording Viewer for SystemC Verification (SCV) library&apos;s transaction recording
</description> </description>
</category-def> </category-def>
<category-def name="com.minres.scviewer.e4" label="SCViewer E4 application"/>
</site> </site>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_95PfsHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ide.application" bindingContexts="_95PfuXNmEeWBq8z1Dv39LA"> <application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_95PfsHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ide.application" bindingContexts="_95PfuXNmEeWBq8z1Dv39LA">
<children xsi:type="basic:TrimmedWindow" xmi:id="_95PfsXNmEeWBq8z1Dv39LA" label="SC Viewer" bindingContexts="_95PfunNmEeWBq8z1Dv39LA" width="980" height="700"> <children xsi:type="basic:TrimmedWindow" xmi:id="_95PfsXNmEeWBq8z1Dv39LA" label="SC Viewer" bindingContexts="_95PfunNmEeWBq8z1Dv39LA" width="1280" height="700">
<children xsi:type="advanced:PerspectiveStack" xmi:id="_95QGxnNmEeWBq8z1Dv39LA"> <children xsi:type="advanced:PerspectiveStack" xmi:id="_95QGxnNmEeWBq8z1Dv39LA">
<children xsi:type="advanced:Perspective" xmi:id="_95QGx3NmEeWBq8z1Dv39LA"> <children xsi:type="advanced:Perspective" xmi:id="_95QGx3NmEeWBq8z1Dv39LA">
<children xsi:type="basic:PartSashContainer" xmi:id="_95QGyHNmEeWBq8z1Dv39LA" horizontal="true"> <children xsi:type="basic:PartSashContainer" xmi:id="_95QGyHNmEeWBq8z1Dv39LA" horizontal="true">
@ -144,10 +144,7 @@
<children xsi:type="menu:ToolControl" xmi:id="_YsBi8HfLEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.StatusLine" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl"> <children xsi:type="menu:ToolControl" xmi:id="_YsBi8HfLEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.StatusLine" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl">
<tags>stretch</tags> <tags>stretch</tags>
</children> </children>
<children xsi:type="menu:ToolControl" xmi:id="_VZzJMHdHEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.HeapStatus" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.status.StatusBarControl"> <children xsi:type="menu:ToolControl" xmi:id="_VZzJMHdHEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.HeapStatus" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl">
<tags>Draggable</tags>
</children>
<children xsi:type="menu:ToolControl" xmi:id="_y0ZS0HfzEeWwZ-9vrAR2UQ" elementId="org.eclipse.ui.ProgressBar" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.internal.status.StatusBarControl">
<tags>Draggable</tags> <tags>Draggable</tags>
</children> </children>
</trimBars> </trimBars>

View File

@ -26,14 +26,10 @@ import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.jface.action.StatusLineManager; import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.osgi.service.prefs.PreferencesService; import org.osgi.service.prefs.PreferencesService;
import com.minres.scviewer.e4.application.AppModelId; import com.minres.scviewer.e4.application.AppModelId;
import com.minres.scviewer.e4.application.Messages;
/** /**
* The Class StatusBarControl. * The Class StatusBarControl.
@ -58,9 +54,6 @@ public class StatusBarControl {
/** The monitor. */ /** The monitor. */
private SyncedProgressMonitor monitor; private SyncedProgressMonitor monitor;
/** The progress bar. */
private ProgressBar progressBar;
/** /**
* Instantiates a new status bar control. * Instantiates a new status bar control.
* *
@ -84,9 +77,7 @@ public class StatusBarControl {
if (toolControl.getElementId().equals(AppModelId.TOOLCONTROL_ORG_ECLIPSE_UI_STATUSLINE)) { //$NON-NLS-1$ if (toolControl.getElementId().equals(AppModelId.TOOLCONTROL_ORG_ECLIPSE_UI_STATUSLINE)) { //$NON-NLS-1$
createStatusLine(parent, toolControl); createStatusLine(parent, toolControl);
} else if (toolControl.getElementId().equals(AppModelId.TOOLCONTROL_ORG_ECLIPSE_UI_HEAPSTATUS)) { //$NON-NLS-1$ } else if (toolControl.getElementId().equals(AppModelId.TOOLCONTROL_ORG_ECLIPSE_UI_HEAPSTATUS)) { //$NON-NLS-1$
createHeapStatus(parent, toolControl); new HeapStatus(parent, osgiPreverences.getSystemPreferences());
} else if (toolControl.getElementId().equals(AppModelId.TOOLCONTROL_ORG_ECLIPSE_UI_PROGRESSBAR)) { //$NON-NLS-1$
createProgressBar(parent, toolControl);
} }
} }
@ -101,36 +92,6 @@ public class StatusBarControl {
} }
} }
/**
* Creates the progress bar.
*
* @param parent the parent
* @param toolControl the tool control
*/
private void createProgressBar(Composite parent, MToolControl toolControl) {
new Label(parent, SWT.NONE);
progressBar = new ProgressBar(parent, SWT.SMOOTH);
progressBar.setBounds(100, 10, 200, 20);
new Label(parent, SWT.NONE);
monitor=new SyncedProgressMonitor(progressBar);
Job.getJobManager().setProgressProvider(new ProgressProvider() {
@Override
public IProgressMonitor createMonitor(Job job) {
return monitor.addJob(job);
}
});
}
/**
* Creates the heap status.
*
* @param parent the parent
* @param toolControl the tool control
*/
private void createHeapStatus(Composite parent, MToolControl toolControl) {
new HeapStatus(parent, osgiPreverences.getSystemPreferences());
}
/** /**
* Creates the status line. * Creates the status line.
* *
@ -140,6 +101,14 @@ public class StatusBarControl {
private void createStatusLine(Composite parent, MToolControl toolControl) { private void createStatusLine(Composite parent, MToolControl toolControl) {
// IEclipseContext context = modelService.getContainingContext(toolControl); // IEclipseContext context = modelService.getContainingContext(toolControl);
manager.createControl(parent); manager.createControl(parent);
monitor=new SyncedProgressMonitor(manager.getProgressMonitor());
Job.getJobManager().setProgressProvider(new ProgressProvider() {
@Override
public IProgressMonitor createMonitor(Job job) {
return monitor.addJob(job);
}
});
} }
/** /**
@ -160,25 +129,17 @@ public class StatusBarControl {
*/ */
private final class SyncedProgressMonitor extends NullProgressMonitor { private final class SyncedProgressMonitor extends NullProgressMonitor {
// thread-Safe via thread confinement of the UI-Thread
/** The running tasks. */
// (means access only via UI-Thread)
private long runningTasks = 0L;
/** The progress bar. */ /** The progress bar. */
private ProgressBar progressBar; private IProgressMonitor progressBar;
/** /**
* Instantiates a new synced progress monitor. * Instantiates a new synced progress monitor.
* *
* @param progressBar the progress bar * @param iProgressMonitor the progress bar
*/ */
public SyncedProgressMonitor(ProgressBar progressBar) { public SyncedProgressMonitor(IProgressMonitor iProgressMonitor) {
super(); super();
this.progressBar = progressBar; this.progressBar = iProgressMonitor;
runningTasks=0;
progressBar.setSelection(0);
progressBar.setEnabled(false);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -189,13 +150,41 @@ public class StatusBarControl {
sync.asyncExec(new Runnable() { sync.asyncExec(new Runnable() {
@Override @Override
public void run() { public void run() {
runningTasks++; progressBar.beginTask(name, totalWork);
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); * This implementation does nothing.
* Subclasses may override this method to do something
* with the name of the task.
*
* @see IProgressMonitor#setTaskName(String)
*/
@Override
public void setTaskName(String name) {
sync.asyncExec(new Runnable() {
@Override
public void run() {
progressBar.setTaskName(name);
}
});
}
/**
* This implementation does nothing.
* Subclasses may override this method to do interesting
* processing when a subtask begins.
*
* @see IProgressMonitor#subTask(String)
*/
@Override
public void subTask(String name) {
sync.asyncExec(new Runnable() {
@Override
public void run() {
progressBar.subTask(name);
} }
}); });
} }
@ -208,7 +197,16 @@ public class StatusBarControl {
sync.asyncExec(new Runnable() { sync.asyncExec(new Runnable() {
@Override @Override
public void run() { public void run() {
progressBar.setSelection(progressBar.getSelection() + work); progressBar.worked(work);
}
});
}
@Override
public void done() {
sync.asyncExec(new Runnable() {
@Override
public void run() {
progressBar.done();
} }
}); });
} }
@ -228,14 +226,8 @@ public class StatusBarControl {
@Override @Override
public void run() { public void run() {
if(event.getResult()==null) return; if(event.getResult()==null) return;
if(runningTasks>0) runningTasks--; if(!event.getResult().isOK())
if (runningTasks > 0){ // --- some tasks are still running --- progressBar.done();
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);
}
} }
}); });
// clean-up // clean-up

View File

@ -0,0 +1,230 @@
package com.minres.scviewer.e4.application.internal.status;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.action.StatusLineLayoutData;
import org.eclipse.jface.resource.JFaceColors;
/**
* Contribution item for the status line.
* @since 2.0
*/
public class StatusLineContributionItem extends ContributionItem {
/**
* Internal mouse listener to track double clicking the status line item.
* @since 3.0
*/
private class Listener extends MouseAdapter {
@Override
public void mouseDoubleClick(MouseEvent e) {
if (fActionHandler != null && fActionHandler.isEnabled())
fActionHandler.run();
}
}
/**
* Left and right margin used in CLabel.
* @since 2.1
*/
private static final int INDENT= 3;
/**
* Default number of characters that should fit into the item.
* @since 3.0
*/
static final int DEFAULT_WIDTH_IN_CHARS = 19;
/**
* Pre-computed label width hint.
* @since 2.1
*/
private int fFixedWidth= -1;
/**
* Pre-computed label height hint.
* @since 3.0
*/
private int fFixedHeight= -1;
/** The text */
private String fText;
/** The image */
private Image fImage;
/**
* The error text.
* @since 3.0
*/
private String fErrorText;
/**
* The error image.
* @since 3.0
*/
private Image fErrorImage;
/**
* The tool tip text.
* @since 3.0
*/
private String fToolTipText;
/**
* Number of characters that should fit into the item.
* @since 3.0
*/
private int fWidthInChars;
/** The status line label widget */
private CLabel fLabel;
/**
* The action handler.
* @since 3.0
*/
private IAction fActionHandler;
/**
* The mouse listener
* @since 3.0
*/
private MouseListener fMouseListener;
/**
* Creates a new item with the given attributes.
*
* @param id the item's id
* @param visible the visibility of this item
* @param widthInChars the width in characters
* @since 3.0
*/
public StatusLineContributionItem(String id, boolean visible, int widthInChars) {
super(id);
setVisible(visible);
fWidthInChars= widthInChars;
}
@Override
public void fill(Composite parent) {
Label sep= new Label(parent, SWT.SEPARATOR);
CLabel label=new CLabel(parent, SWT.SHADOW_NONE);
label.setText(getId());
fLabel= new CLabel(parent, SWT.SHADOW_IN);
fLabel.setAlignment(SWT.RIGHT);
fLabel.addDisposeListener(e -> fMouseListener = null);
if (fActionHandler != null) {
fMouseListener= new Listener();
fLabel.addMouseListener(fMouseListener);
}
StatusLineLayoutData data= new StatusLineLayoutData();
data.widthHint= getWidthHint(parent);
fLabel.setLayoutData(data);
data= new StatusLineLayoutData();
data.heightHint= getHeightHint(parent);
sep.setLayoutData(data);
updateMessageLabel();
}
public void setActionHandler(IAction actionHandler) {
if (fActionHandler != null && actionHandler == null && fMouseListener != null) {
if (!fLabel.isDisposed())
fLabel.removeMouseListener(fMouseListener);
fMouseListener= null;
}
fActionHandler= actionHandler;
if (fLabel != null && !fLabel.isDisposed() && fMouseListener == null && fActionHandler != null) {
fMouseListener= new Listener();
fLabel.addMouseListener(fMouseListener);
}
}
/**
* Returns the width hint for this label.
*
* @param control the root control of this label
* @return the width hint for this label
* @since 2.1
*/
private int getWidthHint(Composite control) {
if (fFixedWidth < 0) {
GC gc= new GC(control);
gc.setFont(control.getFont());
fFixedWidth = (int) gc.getFontMetrics().getAverageCharacterWidth() * fWidthInChars;
fFixedWidth += INDENT * 2;
gc.dispose();
}
return fFixedWidth;
}
/**
* Returns the height hint for this label.
*
* @param control the root control of this label
* @return the height hint for this label
* @since 3.0
*/
private int getHeightHint(Composite control) {
if (fFixedHeight < 0) {
GC gc= new GC(control);
gc.setFont(control.getFont());
fFixedHeight= gc.getFontMetrics().getHeight();
gc.dispose();
}
return fFixedHeight;
}
/**
* Updates the message label widget.
*
* @since 3.0
*/
private void updateMessageLabel() {
if (fLabel != null && !fLabel.isDisposed()) {
Display display= fLabel.getDisplay();
if ((fErrorText != null && !fErrorText.isEmpty()) || fErrorImage != null) {
fLabel.setForeground(JFaceColors.getErrorText(display));
fLabel.setText(fErrorText);
fLabel.setImage(fErrorImage);
if (fToolTipText != null)
fLabel.setToolTipText(fToolTipText);
else if (fErrorText.length() > fWidthInChars)
fLabel.setToolTipText(fErrorText);
else
fLabel.setToolTipText(null);
} else {
fLabel.setForeground(fLabel.getParent().getForeground());
fLabel.setText(fText);
fLabel.setImage(fImage);
if (fToolTipText != null)
fLabel.setToolTipText(fToolTipText);
else if (fText != null && fText.length() > fWidthInChars)
fLabel.setToolTipText(fText);
else
fLabel.setToolTipText(null);
}
}
}
public void setText(String message){
this.fText=message;
updateMessageLabel();
}
public void setErrorText(String message){
this.fErrorText=message;
updateMessageLabel();
}
}

View File

@ -0,0 +1,72 @@
package com.minres.scviewer.e4.application.internal.status;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
/**
* The Class TextContributionItem.
*/
class TextContributionItem extends ContributionItem {
/** The label string. */
final String labelString;
/** The text. */
CLabel label, text;
/** The content. */
private String content;
/**
* Instantiates a new text contribution item.
*
* @param labelString the label string
*/
public TextContributionItem(String labelString) {
super();
this.labelString = labelString;
content=""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Composite)
*/
@Override
public void fill(Composite parent) {
Composite box=new Composite(parent, SWT.NONE); //NONE
box.setLayout(new GridLayout(2, false));
label=new CLabel(box, SWT.SHADOW_NONE);
label.setText(labelString);
text=new CLabel(box, SWT.SHADOW_IN);
text.setAlignment(SWT.RIGHT);
text.setText(" ");
Point p = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
GridData layoutData=new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
layoutData.minimumWidth=12*p.x;
text.setLayoutData(layoutData);
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#isDynamic()
*/
@Override
public boolean isDynamic() {
return true;
}
/**
* Sets the text.
*
* @param message the new text
*/
public void setText(String message){
this.content=message;
if(text!=null && !text.isDisposed()) text.setText(content);
}
}

View File

@ -23,6 +23,10 @@ import org.eclipse.jface.action.StatusLineManager;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -50,76 +54,9 @@ public class WaveStatusBarControl extends StatusBarControl {
@Inject @Inject
EModelService modelService; EModelService modelService;
/**
* The Class TextContributionItem.
*/
class TextContributionItem extends ContributionItem {
/** The label string. */
final String labelString;
/** The width. */
//final int width;
/** The text. */
CLabel label, text;
/** The content. */
private String content;
/**
* Instantiates a new text contribution item.
*
* @param labelString the label string
* @param width the width
*/
public TextContributionItem(String labelString /*, int width */) {
super();
this.labelString = labelString;
//this.width=width;
content=""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Composite)
*/
@Override
public void fill(Composite parent) {
Composite box=new Composite(parent, SWT.NONE); //NONE
box.setLayout(new GridLayout(2, false));
label=new CLabel(box, SWT.SHADOW_NONE);
label.setText(labelString);
text=new CLabel(box, SWT.SHADOW_IN);
text.setAlignment(SWT.RIGHT);
//GridData layoutData=new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
GridData layoutData=new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false);
layoutData.minimumWidth=70;
//layoutData.minimumWidth=width;
text.setLayoutData(layoutData);
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#isDynamic()
*/
@Override
public boolean isDynamic() {
return true;
}
/**
* Sets the text.
*
* @param message the new text
*/
public void setText(String message){
this.content=message;
if(text!=null && !text.isDisposed()) text.setText(content);
}
}
/** The zoom contribution. */ /** The zoom contribution. */
TextContributionItem cursorContribution, markerContribution, markerDiffContribution, zoomContribution; StatusLineContributionItem cursorContribution, markerContribution, markerDiffContribution, zoomContribution;
/** /**
* Instantiates a new wave status bar control. * Instantiates a new wave status bar control.
@ -130,10 +67,10 @@ public class WaveStatusBarControl extends StatusBarControl {
public WaveStatusBarControl(UISynchronize sync) { public WaveStatusBarControl(UISynchronize sync) {
super(sync); super(sync);
cursorContribution = new TextContributionItem(Messages.WaveStatusBarControl_5 /*, 150 */); //150 cursorContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_5, true, 20);
markerContribution = new TextContributionItem(Messages.WaveStatusBarControl_6 /*, 150 */); //150 markerContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_6, true, 20);
markerDiffContribution = new TextContributionItem(Messages.WaveStatusBarControl_7 /*, 150 */); //150 markerDiffContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_7, true, 20);
zoomContribution = new TextContributionItem(Messages.WaveStatusBarControl_8 /*, 60 */); //60 zoomContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_8, true, 8);
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,cursorContribution); manager.appendToGroup(StatusLineManager.BEGIN_GROUP,cursorContribution);
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerContribution); manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerContribution);
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerDiffContribution); manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerDiffContribution);

View File

@ -34,13 +34,9 @@ import javax.inject.Named;
import org.eclipse.core.internal.preferences.InstancePreferences; import org.eclipse.core.internal.preferences.InstancePreferences;
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.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job; 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.jobs.JobGroup;
import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
@ -535,9 +531,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
monitor.setTaskName(Messages.WaveformViewer_16+file.getName());
boolean res = database.load(file); boolean res = database.load(file);
monitor.done();
database.addPropertyChangeListener(waveformPane); database.addPropertyChangeListener(waveformPane);
return res?Status.OK_STATUS:Status.CANCEL_STATUS; return res?Status.OK_STATUS:Status.CANCEL_STATUS;
} }
@ -549,15 +543,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/ */
protected void loadDatabase(final Map<String, String> state) { protected void loadDatabase(final Map<String, String> state) {
fileMonitor.removeFileChangeListener(this); fileMonitor.removeFileChangeListener(this);
MultiStatus fStatus= new MultiStatus("blah", IStatus.OK, Messages.WaveformViewer_13, null);
Job job = new Job(Messages.WaveformViewer_15) { Job job = new Job(Messages.WaveformViewer_15) {
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, filesToLoad.size()); IProgressMonitor progressGroup = getJobManager().createProgressGroup();
JobGroup jobGroup = new JobGroup(Messages.WaveformViewer_15, filesToLoad.size(), filesToLoad.size()); JobGroup jobGroup = new JobGroup(Messages.WaveformViewer_15, filesToLoad.size(), filesToLoad.size());
filesToLoad.forEach((final File file) -> { filesToLoad.forEach((final File file) -> {
Job job = new DbLoadJob(Messages.WaveformViewer_16 + file.getName(), file); Job job = new DbLoadJob(Messages.WaveformViewer_16 + file.getName(), file);
job.setProgressGroup(subMonitor, 1); job.setProgressGroup(progressGroup, 1);
job.setJobGroup(jobGroup); job.setJobGroup(jobGroup);
job.schedule(); job.schedule();
}); });
@ -569,34 +562,28 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
if (monitor.isCanceled()) if (monitor.isCanceled())
throw new OperationCanceledException(Messages.WaveformViewer_14); throw new OperationCanceledException(Messages.WaveformViewer_14);
fStatus.addAll(jobGroup.getResult());
return fStatus; IStatus result = jobGroup.getResult();
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
IStatus result = event.getResult();
if( (!result.isMultiStatus() && result.getCode() != Status.OK_STATUS.getCode() ) || if( (!result.isMultiStatus() && result.getCode() != Status.OK_STATUS.getCode() ) ||
(result.isMultiStatus() && result.getChildren().length > 0 && result.getChildren()[0].getCode() != Status.OK_STATUS.getCode() ) ){ (result.isMultiStatus() && result.getChildren().length > 0 && result.getChildren()[0].getCode() != Status.OK_STATUS.getCode() ) ){
// kill editor and pop up warning for user // kill editor and pop up warning for user
sync.asyncExec(() -> { sync.asyncExec(() -> {
final Display display = myParent.getDisplay(); final Display display = myParent.getDisplay();
MessageDialog.openWarning(display.getActiveShell(), "Error loading database", "Database cannot be loaded. Aborting..."); MessageDialog.openWarning(display.getActiveShell(), "Error loading database", "Database cannot be loaded. Aborting...");
ePartService.hidePart(myPart, true); ePartService.hidePart(myPart, true);
}); });
return; } else
} sync.asyncExec(()->{
sync.asyncExec(()->{ waveformPane.setMaxTime(database.getMaxTime());
waveformPane.setMaxTime(database.getMaxTime()); if (state != null)
if (state != null) restoreWaveformViewerState(state);
restoreWaveformViewerState(state); fileChecker = null;
fileChecker = null; if (checkForUpdates)
if (checkForUpdates) fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL);
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL); });
}); return result;
} }
}); };
job.setSystem(true); job.setSystem(true);
job.schedule(1000L); // let the UI initialize so that we have a progress monitor job.schedule(1000L); // let the UI initialize so that we have a progress monitor
} }