- small refactoring of part class names

- tried to improve Javadoc
This commit is contained in:
2015-11-22 12:47:07 +01:00
parent af1b3d00dc
commit f723a770c7
34 changed files with 926 additions and 122 deletions

View File

@ -27,19 +27,31 @@ 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.WaveformViewerPart;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
/**
* The Class NavigateContribution. Currently not used in Application.e4xmi
*/
public class NavigateContribution {
/** 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 WaveformViewerPart){
WaveformViewerPart waveformViewerPart = (WaveformViewerPart) part.getObject();
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);

View File

@ -32,24 +32,41 @@ import org.eclipse.swt.widgets.Composite;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.e4.application.parts.PartListener;
import com.minres.scviewer.e4.application.parts.WaveformViewerPart;
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;
WaveformViewerPart waveformViewerPart;
/** The waveform viewer part. */
WaveformViewer waveformViewerPart;
/** The dummy. */
RelationType dummy = RelationType.create("------------");
/**
* 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);
@ -62,10 +79,13 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
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 WaveformViewerPart){
waveformViewerPart=(WaveformViewerPart) part.getObject();
if(part.getObject() instanceof WaveformViewer){
waveformViewerPart=(WaveformViewer) part.getObject();
checkSelection(waveformViewerPart.getSelection());
} else {
waveformViewerPart=null;
@ -73,14 +93,25 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
}
}
/**
* 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 WaveformViewerPart && comboViewer!=null){
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();
@ -94,11 +125,14 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
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 WaveformViewerPart && !event.getSelection().isEmpty()){
WaveformViewerPart waveformViewerPart=(WaveformViewerPart) part.getObject();
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());