Search in sources :

Example 1 with StatechartDiagramEditor

use of org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor in project statecharts by Yakindu.

the class DocumentationMenuAction method run.

@Override
public void run() {
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor instanceof StatechartDiagramEditor) {
        Diagram diagram = ((StatechartDiagramEditor) activeEditor).getDiagram();
        List<View> result = EcoreUtil2.getAllContentsOfType(diagram, View.class);
        ToggleShowDocumentationCommand.toggleDocumentation(result);
    }
}
Also used : IEditorPart(org.eclipse.ui.IEditorPart) StatechartDiagramEditor(org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor) View(org.eclipse.gmf.runtime.notation.View) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 2 with StatechartDiagramEditor

use of org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor in project statecharts by Yakindu.

the class CreationWizard method openDiagram.

protected boolean openDiagram(Resource diagram) throws PartInitException {
    String path = diagram.getURI().toPlatformString(true);
    IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
    if (workspaceResource instanceof IFile) {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        StatechartDiagramEditor editor = (StatechartDiagramEditor) page.openEditor(new FileEditorInput((IFile) workspaceResource), getEditorID());
        if (editor != null) {
            List<EObject> allNotationElements = EcoreUtil2.eAllContentsAsList(diagram);
            for (EObject eObject : allNotationElements) {
                if (eObject instanceof View && ((View) eObject).getType().equals(SemanticHints.STATE_NAME)) {
                    IGraphicalEditPart editPart = EditPartUtils.findEditPartForSemanticElement(editor.getDiagramGraphicalViewer().getRootEditPart(), ((View) eObject).getElement());
                    editPart = editPart.getChildBySemanticHint(SemanticHints.STATE_NAME);
                    if (editPart != null) {
                        final DirectEditRequest request = new DirectEditRequest();
                        request.setDirectEditFeature(BasePackage.Literals.NAMED_ELEMENT__NAME);
                        editPart.performRequest(request);
                        break;
                    }
                }
            }
            return false;
        }
    }
    return false;
}
Also used : Path(org.eclipse.core.runtime.Path) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IFile(org.eclipse.core.resources.IFile) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) FileEditorInput(org.eclipse.ui.part.FileEditorInput) EObject(org.eclipse.emf.ecore.EObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) StatechartDiagramEditor(org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor) View(org.eclipse.gmf.runtime.notation.View) IResource(org.eclipse.core.resources.IResource)

Example 3 with StatechartDiagramEditor

use of org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor in project statecharts by Yakindu.

the class DocumentationDropDownAction method run.

public void run() {
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor instanceof StatechartDiagramEditor) {
        Diagram diagram = ((StatechartDiagramEditor) activeEditor).getDiagram();
        List<View> result = EcoreUtil2.getAllContentsOfType(diagram, View.class);
        show(result);
    }
}
Also used : IEditorPart(org.eclipse.ui.IEditorPart) StatechartDiagramEditor(org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor) View(org.eclipse.gmf.runtime.notation.View) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 4 with StatechartDiagramEditor

use of org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor in project statecharts by Yakindu.

the class ExtractSubdiagramRefactoring method getActualBounds.

protected Rectangle getActualBounds(Node child) {
    IEditorPart lastActiveEditor = ActiveEditorTracker.getLastActiveEditor();
    if (lastActiveEditor instanceof StatechartDiagramEditor) {
        IDiagramGraphicalViewer viewer = ((StatechartDiagramEditor) lastActiveEditor).getDiagramGraphicalViewer();
        IGraphicalEditPart editPart = (IGraphicalEditPart) viewer.getEditPartRegistry().get(child);
        return editPart.getFigure().getBounds();
    }
    return Rectangle.SINGLETON;
}
Also used : IDiagramGraphicalViewer(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IEditorPart(org.eclipse.ui.IEditorPart) StatechartDiagramEditor(org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor)

Aggregations

StatechartDiagramEditor (org.yakindu.sct.ui.editor.editor.StatechartDiagramEditor)4 View (org.eclipse.gmf.runtime.notation.View)3 IEditorPart (org.eclipse.ui.IEditorPart)3 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 Diagram (org.eclipse.gmf.runtime.notation.Diagram)2 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 Path (org.eclipse.core.runtime.Path)1 EObject (org.eclipse.emf.ecore.EObject)1 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)1 IDiagramGraphicalViewer (org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1