Search in sources :

Example 1 with TextAwareLabelEditPart

use of org.yakindu.base.gmf.runtime.editparts.TextAwareLabelEditPart in project statecharts by Yakindu.

the class StatechartMarkerNavigationProvider method doGotoMarker.

@Override
@SuppressWarnings("rawtypes")
protected void doGotoMarker(IMarker marker) {
    String elementId = marker.getAttribute(SCTMarkerType.SEMANTIC_ELEMENT_ID, null);
    if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
        return;
    }
    DiagramEditor editor = (DiagramEditor) getEditor();
    EObject targetElement = (EObject) editor.getDiagram().eResource().getEObject(elementId);
    if (targetElement == null) {
        return;
    }
    View view = DiagramPartitioningUtil.findNotationView(targetElement);
    if (view == null) {
        return;
    }
    Diagram element = DiagramPartitioningUtil.getDiagramContaining(view.getElement());
    editor = (DiagramEditor) DiagramPartitioningUtil.openEditor(element);
    Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
    EditPart targetEditPart = (EditPart) editPartRegistry.get(view);
    if (targetEditPart != null) {
        if (!targetEditPart.isSelectable())
            return;
        DiagramPartitioningUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart }));
    }
    try {
        if (marker.isSubtypeOf(SCTMarkerType.SUPERTYPE)) {
            final DirectEditRequest request = new DirectEditRequest();
            request.setDirectEditFeature(getEditFeature(targetElement, marker));
            List<IGraphicalEditPart> allEditParts = getEditParts(editPartRegistry, EcoreUtil2.eAllContentsAsList(view));
            for (IGraphicalEditPart editPart : allEditParts) {
                if (editPart instanceof IXtextAwareEditPart || (editPart instanceof TextAwareLabelEditPart) && ((TextAwareLabelEditPart) editPart).getFeature().equals(request.getDirectEditFeature())) {
                    editPart.performRequest(request);
                    break;
                }
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) DiagramEditor(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor) TextAwareLabelEditPart(org.yakindu.base.gmf.runtime.editparts.TextAwareLabelEditPart) IXtextAwareEditPart(org.yakindu.base.xtext.utils.gmf.directedit.IXtextAwareEditPart) EditPart(org.eclipse.gef.EditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) View(org.eclipse.gmf.runtime.notation.View) Diagram(org.eclipse.gmf.runtime.notation.Diagram) CoreException(org.eclipse.core.runtime.CoreException) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) TextAwareLabelEditPart(org.yakindu.base.gmf.runtime.editparts.TextAwareLabelEditPart) EObject(org.eclipse.emf.ecore.EObject) IXtextAwareEditPart(org.yakindu.base.xtext.utils.gmf.directedit.IXtextAwareEditPart) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 CoreException (org.eclipse.core.runtime.CoreException)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 DiagramEditor (org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor)1 Diagram (org.eclipse.gmf.runtime.notation.Diagram)1 View (org.eclipse.gmf.runtime.notation.View)1 TextAwareLabelEditPart (org.yakindu.base.gmf.runtime.editparts.TextAwareLabelEditPart)1 IXtextAwareEditPart (org.yakindu.base.xtext.utils.gmf.directedit.IXtextAwareEditPart)1