Added handler and configurability of wavefrom view
This commit is contained in:
@ -1,34 +1,44 @@
|
||||
|
||||
package com.minres.scviewer.e4.application.elements;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.ui.di.AboutToShow;
|
||||
import org.eclipse.e4.core.di.annotations.Evaluate;
|
||||
import org.eclipse.e4.ui.di.AboutToHide;
|
||||
import org.eclipse.e4.ui.di.AboutToShow;
|
||||
import org.eclipse.e4.ui.model.application.MApplication;
|
||||
import org.eclipse.e4.ui.model.application.commands.MCommand;
|
||||
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
|
||||
import org.eclipse.e4.ui.model.application.commands.MParameter;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem;
|
||||
import org.eclipse.e4.ui.model.application.ui.menu.ItemType;
|
||||
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
||||
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
|
||||
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.ISignalChange;
|
||||
import com.minres.scviewer.database.ISignalChangeBit;
|
||||
import com.minres.scviewer.database.ISignalChangeBitVector;
|
||||
import com.minres.scviewer.database.ISignalChangeReal;
|
||||
import com.minres.scviewer.database.ui.GotoDirection;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class WaveformPopupMenuContribution {
|
||||
int counter=0;
|
||||
|
||||
@Inject MPart activePart;
|
||||
|
||||
final TrackEntry nullEntry = new TrackEntry(null);
|
||||
|
||||
@AboutToShow
|
||||
public void aboutToShow(List<MMenuElement> items) {
|
||||
@Evaluate
|
||||
public boolean evaluate() {
|
||||
Object obj = activePart.getObject();
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer wfv = (WaveformViewer)obj;
|
||||
@ -37,27 +47,82 @@ public class WaveformPopupMenuContribution {
|
||||
Object selected = ((IStructuredSelection)sel).getFirstElement();
|
||||
if(selected instanceof ISignal<?>) {
|
||||
ISignalChange s = (ISignalChange) ((ISignal<?>) selected).getEvents().firstEntry().getValue();
|
||||
if(s instanceof ISignalChangeReal) {
|
||||
MDirectMenuItem mdi = MMenuFactory.INSTANCE.createDirectMenuItem();
|
||||
mdi.setLabel("Analog linear");
|
||||
items.add(mdi);
|
||||
mdi = MMenuFactory.INSTANCE.createDirectMenuItem();
|
||||
mdi.setLabel("Analog step");
|
||||
items.add(mdi);
|
||||
} else if(s instanceof ISignalChangeBitVector) {
|
||||
MDirectMenuItem mdi = MMenuFactory.INSTANCE.createDirectMenuItem();
|
||||
mdi.setLabel("Analog linear");
|
||||
items.add(mdi);
|
||||
mdi = MMenuFactory.INSTANCE.createDirectMenuItem();
|
||||
mdi.setLabel("Analog step");
|
||||
items.add(mdi);
|
||||
if((s instanceof ISignalChangeReal) || (s instanceof ISignalChangeBitVector)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@AboutToShow
|
||||
public void aboutToShow(List<MMenuElement> items, MApplication application, EModelService modelService) {
|
||||
Object obj = activePart.getObject();
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer wfv = (WaveformViewer)obj;
|
||||
ISelection sel = wfv.getSelection();
|
||||
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
Iterator<?> it = ((IStructuredSelection)sel).iterator();
|
||||
Object first = it.next();
|
||||
Object second=null;
|
||||
if(it.hasNext()) second=it.next();
|
||||
if(first instanceof ISignal<?>) {
|
||||
ISignalChange s = (ISignalChange) ((ISignal<?>) first).getEvents().firstEntry().getValue();
|
||||
//com.minres.scviewer.e4.application.menu.mulitvaluesettings
|
||||
if((s instanceof ISignalChangeReal) || (s instanceof ISignalChangeBitVector)) {
|
||||
TrackEntry entry=nullEntry;
|
||||
if(second instanceof TrackEntry)
|
||||
entry=(TrackEntry)second;
|
||||
if(s instanceof ISignalChangeBitVector) {
|
||||
addValueMenuItem(items, application, modelService, "hex", TrackEntry.ValueDisplay.DEFAULT, entry.valueDisplay);
|
||||
addValueMenuItem(items, application, modelService, "unsigned", TrackEntry.ValueDisplay.UNSIGNED, entry.valueDisplay);
|
||||
addValueMenuItem(items, application, modelService, "signed", TrackEntry.ValueDisplay.SIGNED, entry.valueDisplay);
|
||||
items.add(MMenuFactory.INSTANCE.createMenuSeparator());
|
||||
addWaveMenuItem(items, application, modelService, "bit vector", TrackEntry.WaveDisplay.DEFAULT, entry.waveDisplay);
|
||||
}
|
||||
addWaveMenuItem(items, application, modelService, "analog step-wise", TrackEntry.WaveDisplay.STEP_WISE, entry.waveDisplay);
|
||||
addWaveMenuItem(items, application, modelService, "analog continous", TrackEntry.WaveDisplay.CONTINOUS, entry.waveDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addValueMenuItem(List<MMenuElement> items, MApplication application, EModelService modelService,
|
||||
String label, TrackEntry.ValueDisplay value, TrackEntry.ValueDisplay actual) {
|
||||
MHandledMenuItem item = MMenuFactory.INSTANCE.createHandledMenuItem();
|
||||
item.setType(ItemType.RADIO);
|
||||
item.setSelected(value==actual);
|
||||
item.setLabel("Show as "+label);
|
||||
item.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application");
|
||||
List<MCommand> cmds = modelService.findElements(application, "com.minres.scviewer.e4.application.command.changevaluedisplay", MCommand.class, null);
|
||||
if(cmds.size()!=1) System.err.println("No command found!");
|
||||
else item.setCommand(cmds.get(0));
|
||||
MParameter param = MCommandsFactory.INSTANCE.createParameter();
|
||||
param.setName("com.minres.scviewer.e4.application.commandparameter.changevaluedisplay");
|
||||
param.setValue(value.toString());
|
||||
item.getParameters().add(param);
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
private void addWaveMenuItem(List<MMenuElement> items, MApplication application, EModelService modelService,
|
||||
String label, TrackEntry.WaveDisplay value, TrackEntry.WaveDisplay actual) {
|
||||
MHandledMenuItem item = MMenuFactory.INSTANCE.createHandledMenuItem();
|
||||
item.setType(ItemType.RADIO);
|
||||
item.setSelected(value==actual);
|
||||
item.setLabel("Render "+label);
|
||||
item.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application");
|
||||
List<MCommand> cmds = modelService.findElements(application, "com.minres.scviewer.e4.application.command.changewavedisplay", MCommand.class, null);
|
||||
if(cmds.size()!=1) System.err.println("No command found!");
|
||||
else item.setCommand(cmds.get(0));
|
||||
MParameter param = MCommandsFactory.INSTANCE.createParameter();
|
||||
param.setName("com.minres.scviewer.e4.application.commandparameter.changewavedisplay");
|
||||
param.setValue(value.toString());
|
||||
item.getParameters().add(param);
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
@AboutToHide
|
||||
public void aboutToHide(List<MMenuElement> items) {
|
||||
|
@ -10,6 +10,8 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.MApplication;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MDialog;
|
||||
@ -19,9 +21,11 @@ import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class AboutHandler {
|
||||
|
||||
static final String DIALOG_ID="com.minres.scviewer.e4.application.dialog.aboutscviewer";
|
||||
|
||||
@Execute
|
||||
public void execute(Shell shell, MApplication app, MWindow window, EModelService ms /*@Named("mdialog01.dialog.0") MDialog dialog*/) {
|
||||
MDialog dialog = (MDialog) ms.find("com.minres.scviewer.e4.application.dialog.aboutscviewer", app); //$NON-NLS-1$
|
||||
MDialog dialog = (MDialog) ms.find(DIALOG_ID, app); //$NON-NLS-1$
|
||||
dialog.setToBeRendered(true);
|
||||
dialog.setToBeRendered(false);
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class ChangeValueDisplay {
|
||||
|
||||
static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.changevaluedisplay"; //$NON-NLS-1$
|
||||
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
if(part==null) return false;
|
||||
return (part.getObject() instanceof WaveformViewer);
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer wfv = (WaveformViewer)obj;
|
||||
ISelection sel = wfv.getSelection();
|
||||
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
Iterator<?> it = ((IStructuredSelection)sel).iterator();
|
||||
it.next();
|
||||
if(it.hasNext()) {
|
||||
Object second = it.next();
|
||||
if(second instanceof TrackEntry) {
|
||||
TrackEntry.ValueDisplay val = TrackEntry.ValueDisplay.valueOf(param);
|
||||
((TrackEntry)second).valueDisplay=val;
|
||||
wfv.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.CanExecute;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class ChangeWaveformDisplay {
|
||||
|
||||
static final String PARAMETER_ID="com.minres.scviewer.e4.application.commandparameter.changewavedisplay"; //$NON-NLS-1$
|
||||
|
||||
@CanExecute
|
||||
public boolean canExecute(EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
if(part==null) return false;
|
||||
return (part.getObject() instanceof WaveformViewer);
|
||||
}
|
||||
|
||||
@Execute
|
||||
public void execute(@Named(PARAMETER_ID) String param, EPartService partService) {
|
||||
MPart part = partService.getActivePart();
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer wfv = (WaveformViewer)obj;
|
||||
ISelection sel = wfv.getSelection();
|
||||
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
Iterator<?> it = ((IStructuredSelection)sel).iterator();
|
||||
it.next();
|
||||
if(it.hasNext()) {
|
||||
Object second = it.next();
|
||||
if(second instanceof TrackEntry) {
|
||||
TrackEntry.WaveDisplay val= TrackEntry.WaveDisplay.valueOf(param);
|
||||
((TrackEntry)second).waveDisplay=val;
|
||||
wfv.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -744,7 +744,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
//FIXME: need to use unitString and unitMultiplier from class WaveformCanvas which is located in >com.minres.scviewer.database.swt.internal.
|
||||
//Trying to import com.minres.scviewer.database.swt.internal.WaveformCanvas results in the error:
|
||||
//'Access restriction: The type 'WaveformCanvas' is not API (restriction on required project 'com.minres.scviewer.database.ui.swt')'.
|
||||
public final static String[] unitString={"fs", "ps", "ns", "<EFBFBD>s", "ms"};//, "s"};
|
||||
public final static String[] unitString={"fs", "ps", "ns", "<EFBFBD>s", "ms"};//, "s"};
|
||||
public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300};
|
||||
|
||||
/**
|
||||
@ -919,5 +919,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
if(navigationRelationType!=relationType) waveformPane.setHighliteRelation(relationType);
|
||||
navigationRelationType=relationType;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
waveformPane.update();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user