[WIP ]reorganized dir structure

This commit is contained in:
2020-06-01 17:26:56 +02:00
parent 3e5ab7b0ac
commit 97693cd0c4
374 changed files with 43 additions and 390 deletions

View File

@ -0,0 +1,88 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
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.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MCommandParameter;
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.MHandledMenuItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
/**
* The Class NavigateContribution. Currently not used in Application.e4xmi
*/
public class NavigateToolbarContribution {
/** The part service. */
@Inject EPartService partService;
/**
* About to show.
*
* @param items the items
* @param application the application
* @param modelService the model service
*/
@AboutToShow
public void aboutToShow(List<MMenuElement> items, MApplication application, EModelService modelService) {
// modelService.getActivePerspective(window)
// modelService.findElements(application,"myID",MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE);
// MDirectMenuItem dynamicItem = MMenuFactory.INSTANCE.createDirectMenuItem();
MPart part = partService.getActivePart();
if(part.getObject()instanceof WaveformViewer){
WaveformViewer waveformViewerPart = (WaveformViewer) part.getObject();
RelationType relationTypeFilter = waveformViewerPart.getRelationTypeFilter();
MCommand command = modelService.findElements(application,
"com.minres.scviewer.e4.application.command.setrelationtype", MCommand.class, null).get(0); //$NON-NLS-1$
MCommandParameter commandParameter = command.getParameters().get(0);
for(RelationType relationType:waveformViewerPart.getAllRelationTypes()){
// MDirectMenuItem dynamicItem = modelService.createModelElement(MDirectMenuItem.class);
//
// dynamicItem.setLabel(relationType.getName());
// dynamicItem.setIconURI(relationTypeFilter.equals(relationType)?
// "platform:/plugin/com.minres.scviewer.e4.application/icons/tick.png":
// "platform:/plugin/com.minres.scviewer.e4.application/icons/empty.png");
// dynamicItem.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application");
// dynamicItem.setContributionURI("bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.DirectMenuItem?blah=1");
// items.add(dynamicItem);
MParameter parameter=modelService.createModelElement(MParameter.class);
parameter.setName(commandParameter.getElementId());
parameter.setValue(relationType.getName());
parameter.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application"); //$NON-NLS-1$
MHandledMenuItem handledMenuItem= modelService.createModelElement(MHandledMenuItem.class);
handledMenuItem.setLabel(relationType.getName());
if(relationTypeFilter.equals(relationType)){
handledMenuItem.setEnabled(false);
handledMenuItem.setIconURI("platform:/plugin/com.minres.scviewer.e4.application/icons/tick.png"); //$NON-NLS-1$
}else
handledMenuItem.setIconURI("platform:/plugin/com.minres.scviewer.e4.application/icons/empty.png"); //$NON-NLS-1$
handledMenuItem.setContributorURI("platform:/plugin/com.minres.scviewer.e4.application"); //$NON-NLS-1$
handledMenuItem.setCommand(command);
handledMenuItem.getParameters().add(parameter);
items.add(handledMenuItem);
}
}
}
}

View File

@ -0,0 +1,144 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.e4.application.elements;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.parts.PartListener;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
/**
* The Class RelationTypeToolControl allowing to control which TX relation is used for navigation.
*/
public class RelationTypeToolControl extends PartListener implements ISelectionChangedListener {
/** The part service. */
EPartService partService;
/** The combo viewer. */
ComboViewer comboViewer;
/** The waveform viewer part. */
WaveformViewer waveformViewerPart;
/** The dummy. */
RelationType dummy = RelationType.create(Messages.RelationTypeToolControl_0);
/**
* Instantiates a new relation type tool control.
*
* @param partService the part service
*/
@Inject
public RelationTypeToolControl(EPartService partService) {
this.partService=partService;
partService.addPartListener(this);
}
/**
* Creates the gui.
*
* @param parent the parent
*/
@PostConstruct
public void createGui(Composite parent) {
comboViewer = new ComboViewer(parent, SWT.NONE);
Combo comboBox = comboViewer.getCombo();
comboBox.setBounds(0, 0, 26, 22);
comboBox.setText(Messages.RelationTypeToolControl_1);
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setInput(new RelationType[] {dummy});
comboViewer.setSelection(new StructuredSelection(dummy));
comboViewer.addSelectionChangedListener(this);
}
/* (non-Javadoc)
* @see com.minres.scviewer.e4.application.parts.PartListener#partActivated(org.eclipse.e4.ui.model.application.ui.basic.MPart)
*/
@Override
public void partActivated(MPart part) {
if(part.getObject() instanceof WaveformViewer){
waveformViewerPart=(WaveformViewer) part.getObject();
checkSelection(waveformViewerPart.getSelection());
} else {
waveformViewerPart=null;
checkSelection(new StructuredSelection());
}
}
/**
* Sets the selection.
*
* @param selection the selection
* @param partService the part service
*/
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
MPart part = partService.getActivePart();
if(part!=null && part.getObject() instanceof WaveformViewer && comboViewer!=null){
checkSelection(selection);
}
}
/**
* Check selection.
*
* @param selection the selection
*/
protected void checkSelection(ISelection selection) {
if( selection instanceof IStructuredSelection) {
Object object= ((IStructuredSelection)selection).getFirstElement();
if(object instanceof ITx && waveformViewerPart!=null){
comboViewer.getCombo().setEnabled(true);
comboViewer.setInput(waveformViewerPart.getSelectionRelationTypes());//getAllRelationTypes());
comboViewer.setSelection(new StructuredSelection(waveformViewerPart.getRelationTypeFilter()));
return;
}
}
comboViewer.getCombo().setEnabled(false);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
MPart part = partService.getActivePart();
if(part!=null && part.getObject() instanceof WaveformViewer && !event.getSelection().isEmpty()){
WaveformViewer waveformViewerPart=(WaveformViewer) part.getObject();
if(event.getSelection() instanceof IStructuredSelection){
waveformViewerPart.setNavigationRelationType(
(RelationType)((IStructuredSelection)event.getSelection()).getFirstElement());
}
}
}
}

View File

@ -0,0 +1,130 @@
package com.minres.scviewer.e4.application.elements;
import java.util.Iterator;
import java.util.List;
import javax.inject.Inject;
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.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.BitVector;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class WaveformPopupMenuContribution {
int counter=0;
@Inject MPart activePart;
final TrackEntry nullEntry = new TrackEntry(null);
@Evaluate
public boolean evaluate() {
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<?>) {
Object x = ((ISignal<?>) selected).getEvents().firstEntry().getValue();
if((x instanceof BitVector) && ((BitVector)x).getWidth()==1) {
return false;
} else
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<?>) {
Object o = ((ISignal<?>) first).getEvents().firstEntry().getValue();
//com.minres.scviewer.e4.application.menu.mulitvaluesettings
if((o instanceof Double) || (o instanceof BitVector)) {
TrackEntry entry=nullEntry;
if(second instanceof TrackEntry)
entry=(TrackEntry)second;
if(o instanceof BitVector) {
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) {
}
}