[WIP] extended application to configure waveform display

This commit is contained in:
2018-10-11 14:54:47 +02:00
parent 0634b9cfd5
commit 694423be3b
5 changed files with 99 additions and 30 deletions

View File

@ -32,7 +32,7 @@ import com.minres.scviewer.e4.application.parts.WaveformViewer;
/**
* The Class NavigateContribution. Currently not used in Application.e4xmi
*/
public class NavigateContribution {
public class NavigateToolbarContribution {
/** The part service. */
@Inject EPartService partService;

View File

@ -0,0 +1,67 @@
package com.minres.scviewer.e4.application.elements;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.ui.di.AboutToShow;
import org.eclipse.e4.ui.di.AboutToHide;
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.MMenuElement;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
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.e4.application.parts.WaveformViewer;
public class WaveformPopupMenuContribution {
int counter=0;
@Inject MPart activePart;
@AboutToShow
public void aboutToShow(List<MMenuElement> items) {
Object obj = activePart.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
ISelection sel = wfv.getSelection();
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
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);
}
}
}
}
}
@AboutToHide
public void aboutToHide(List<MMenuElement> items) {
}
}

View File

@ -49,6 +49,7 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
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);