Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Validating all diagrams in a session
Validating all diagrams in a session [message #1850369] Mon, 28 February 2022 07:26 Go to next message
Simon Tulia is currently offline Simon TuliaFriend
Messages: 14
Registered: January 2022
Junior Member
Hello all,

I would like to programmatically validate all diagrams in a session, respectively. For this, I traverse through the diagrams, but encounter with a problem when I get the editor object. This is basically what I am trying to do:

public boolean validateAllDiagrams(EObject self){
    Session session = SessionManager.INSTANCE.getSession(self);
    Collection<DRepresentation> representationList = DialectManager.INSTANCE.getAllRepresentations(session);
    for(DRepresentation rep: representationList ){
        if(rep instanceof DDiagram){
            IEditorPart editorPart = DialectUIManager.INSTANCE.openEditor(session, rep, new NullProgressMonitor());
            WorkbenchPartDescriptor workbenchPartDescriptor = new WorkbenchPartDescriptor(editorPart.getSite().getId(), editorPart.getClass(), editorPart.getSite().getPage());
            ValidateAction va = new ValidateAction(workbenchPartDescriptor);
            va.run();
        }
    }
}

However, during the execution of DialectUIManager.INSTANCE.openEditor function, I am getting the following exception. If the editor has been already opened, the exception does not occur. Actually, I do not need to open the editor, but I could not find any way to get an object related to the editor to call va.run() function [1]. So, I wonder how I can validate all diagrams or access to DialectEditor objects.


!ENTRY org.eclipse.ui 4 4 2022-02-28 10:18:29.505
!MESSAGE Unable to create part
!STACK 1
org.eclipse.ui.PartInitException: Cannot activate read/write transaction in read-only transaction context
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:346)
	at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:999)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:964)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:140)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:405)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:332)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1000)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:660)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:766)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:737)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:731)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:715)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$1.handleEvent(PartServiceImpl.java:107)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4735)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:219)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:132)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:170)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:188)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:658)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:622)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:790)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1263)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3195)
	at org.eclipse.ui.internal.WorkbenchPage.lambda$9(WorkbenchPage.java:3100)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3098)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3068)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3051)
	at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices$1.run(DiagramDialectUIServices.java:221)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4735)
	at org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil.displaySyncExec(EclipseUIUtil.java:337)
	at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices.openEditor(DiagramDialectUIServices.java:234)
	at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices.openEditor(DiagramDialectUIServices.java:187)
	at org.eclipse.sirius.ui.business.internal.dialect.DialectUIManagerImpl.openEditor(DialectUIManagerImpl.java:94)
	at my.design.Validation.validateAll(Validation.java:415)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.acceleo.query.runtime.impl.JavaMethodService.internalInvoke(JavaMethodService.java:162)
	at org.eclipse.acceleo.query.runtime.impl.AbstractService.invoke(AbstractService.java:135)
	at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.callService(EvaluationServices.java:129)
	at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.call(EvaluationServices.java:172)
	at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.callOrApply(EvaluationServices.java:208)
	at org.eclipse.acceleo.query.parser.AstEvaluator.caseCall(AstEvaluator.java:189)
	at org.eclipse.acceleo.query.ast.util.AstSwitch.doSwitch(AstSwitch.java:119)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
	at org.eclipse.acceleo.query.parser.AstEvaluator.eval(AstEvaluator.java:109)
	at org.eclipse.acceleo.query.runtime.impl.QueryEvaluationEngine.eval(QueryEvaluationEngine.java:52)
	at org.eclipse.sirius.common.acceleo.aql.business.internal.AQLSiriusInterpreter.evaluateExpression(AQLSiriusInterpreter.java:218)
	at org.eclipse.sirius.common.acceleo.aql.business.internal.AQLSiriusInterpreter.evaluate(AQLSiriusInterpreter.java:197)
	at org.eclipse.sirius.tools.internal.interpreter.SessionInterpreter.evaluate(SessionInterpreter.java:179)
	at org.eclipse.sirius.common.tools.api.interpreter.IInterpreter.evaluateBoolean(IInterpreter.java:164)
	at org.eclipse.sirius.business.internal.metamodel.description.validation.operations.ValidationRuleOperations.checkRule(ValidationRuleOperations.java:61)
	at org.eclipse.sirius.diagram.tools.api.validation.constraint.AbstractDDiagramConstraint.getFailingRulesFromCollection(AbstractDDiagramConstraint.java:187)
	at org.eclipse.sirius.diagram.tools.api.validation.constraint.AbstractDDiagramConstraint.getFailingRules(AbstractDDiagramConstraint.java:138)
	at org.eclipse.sirius.diagram.tools.api.validation.constraint.AbstractDDiagramConstraint.validate(AbstractDDiagramConstraint.java:62)
	at org.eclipse.emf.validation.internal.util.JavaConstraintParser$ConstraintAdapter.validate(JavaConstraintParser.java:80)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.evaluateConstraints(AbstractValidator.java:241)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:264)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:211)
	at org.eclipse.emf.validation.internal.service.BatchValidator.doValidate(BatchValidator.java:149)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.validate(AbstractValidator.java:147)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.validate(AbstractValidator.java:126)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:1)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.validate(ValidateAction.java:190)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.access$0(ValidateAction.java:179)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction$2.run(ValidateAction.java:159)
	at org.eclipse.sirius.diagram.ui.internal.providers.SiriusValidationProvider$1.run(SiriusValidationProvider.java:75)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.sirius.diagram.ui.internal.providers.SiriusValidationProvider.runWithConstraints(SiriusValidationProvider.java:84)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.runValidation(ValidateAction.java:155)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction$1.run(ValidateAction.java:112)
	at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:71)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.lambda$0(WorkspaceModifyOperation.java:110)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:131)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.run(ValidateAction.java:114)
	at org.eclipse.sirius.diagram.ui.tools.internal.commands.ValidateDiagramCommand.execute(ValidateDiagramCommand.java:43)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
	at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:319)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:253)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:438)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:449)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:475)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4213)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4030)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3630)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1158)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1047)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1447)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1420)
Caused by: java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.acquire(TransactionalEditingDomainImpl.java:576)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.activate(TransactionalEditingDomainImpl.java:508)
	at org.eclipse.emf.transaction.impl.TransactionImpl.start(TransactionImpl.java:204)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorSessionListenerDelegate.reloadPalette(DDiagramEditorSessionListenerDelegate.java:259)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorSessionListenerDelegate.run(DDiagramEditorSessionListenerDelegate.java:193)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.notify(DDiagramEditorImpl.java:1394)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.setInput(DDiagramEditorImpl.java:1977)
	at org.eclipse.gef.ui.parts.GraphicalEditor.init(GraphicalEditor.java:346)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.init(DiagramEditor.java:654)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.init(DiagramDocumentEditor.java:128)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.init(DDiagramEditorImpl.java:569)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:340)
	... 149 more
!SUBENTRY 1 org.eclipse.ui 4 0 2022-02-28 10:18:29.515
!MESSAGE Cannot activate read/write transaction in read-only transaction context
!STACK 0
java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.acquire(TransactionalEditingDomainImpl.java:576)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.activate(TransactionalEditingDomainImpl.java:508)
	at org.eclipse.emf.transaction.impl.TransactionImpl.start(TransactionImpl.java:204)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorSessionListenerDelegate.reloadPalette(DDiagramEditorSessionListenerDelegate.java:259)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorSessionListenerDelegate.run(DDiagramEditorSessionListenerDelegate.java:193)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.notify(DDiagramEditorImpl.java:1394)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.setInput(DDiagramEditorImpl.java:1977)
	at org.eclipse.gef.ui.parts.GraphicalEditor.init(GraphicalEditor.java:346)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.init(DiagramEditor.java:654)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.init(DiagramDocumentEditor.java:128)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl.init(DDiagramEditorImpl.java:569)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:340)
	at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:999)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:964)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:140)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:405)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:332)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:1000)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:660)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:766)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:737)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:731)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:715)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$1.handleEvent(PartServiceImpl.java:107)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4735)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:219)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:132)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:170)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:188)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:658)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:622)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:790)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1263)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3195)
	at org.eclipse.ui.internal.WorkbenchPage.lambda$9(WorkbenchPage.java:3100)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3098)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3068)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3051)
	at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices$1.run(DiagramDialectUIServices.java:221)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4735)
	at org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil.displaySyncExec(EclipseUIUtil.java:337)
	at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices.openEditor(DiagramDialectUIServices.java:234)
	at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices.openEditor(DiagramDialectUIServices.java:187)
	at org.eclipse.sirius.ui.business.internal.dialect.DialectUIManagerImpl.openEditor(DialectUIManagerImpl.java:94)
	at my.design.Validation.validateAll(Validation.java:415)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.acceleo.query.runtime.impl.JavaMethodService.internalInvoke(JavaMethodService.java:162)
	at org.eclipse.acceleo.query.runtime.impl.AbstractService.invoke(AbstractService.java:135)
	at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.callService(EvaluationServices.java:129)
	at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.call(EvaluationServices.java:172)
	at org.eclipse.acceleo.query.runtime.impl.EvaluationServices.callOrApply(EvaluationServices.java:208)
	at org.eclipse.acceleo.query.parser.AstEvaluator.caseCall(AstEvaluator.java:189)
	at org.eclipse.acceleo.query.ast.util.AstSwitch.doSwitch(AstSwitch.java:119)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53)
	at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69)
	at org.eclipse.acceleo.query.parser.AstEvaluator.eval(AstEvaluator.java:109)
	at org.eclipse.acceleo.query.runtime.impl.QueryEvaluationEngine.eval(QueryEvaluationEngine.java:52)
	at org.eclipse.sirius.common.acceleo.aql.business.internal.AQLSiriusInterpreter.evaluateExpression(AQLSiriusInterpreter.java:218)
	at org.eclipse.sirius.common.acceleo.aql.business.internal.AQLSiriusInterpreter.evaluate(AQLSiriusInterpreter.java:197)
	at org.eclipse.sirius.tools.internal.interpreter.SessionInterpreter.evaluate(SessionInterpreter.java:179)
	at org.eclipse.sirius.common.tools.api.interpreter.IInterpreter.evaluateBoolean(IInterpreter.java:164)
	at org.eclipse.sirius.business.internal.metamodel.description.validation.operations.ValidationRuleOperations.checkRule(ValidationRuleOperations.java:61)
	at org.eclipse.sirius.diagram.tools.api.validation.constraint.AbstractDDiagramConstraint.getFailingRulesFromCollection(AbstractDDiagramConstraint.java:187)
	at org.eclipse.sirius.diagram.tools.api.validation.constraint.AbstractDDiagramConstraint.getFailingRules(AbstractDDiagramConstraint.java:138)
	at org.eclipse.sirius.diagram.tools.api.validation.constraint.AbstractDDiagramConstraint.validate(AbstractDDiagramConstraint.java:62)
	at org.eclipse.emf.validation.internal.util.JavaConstraintParser$ConstraintAdapter.validate(JavaConstraintParser.java:80)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.evaluateConstraints(AbstractValidator.java:241)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:264)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:211)
	at org.eclipse.emf.validation.internal.service.BatchValidator.doValidate(BatchValidator.java:149)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.validate(AbstractValidator.java:147)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.validate(AbstractValidator.java:126)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:1)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.validate(ValidateAction.java:190)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.access$0(ValidateAction.java:179)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction$2.run(ValidateAction.java:159)
	at org.eclipse.sirius.diagram.ui.internal.providers.SiriusValidationProvider$1.run(SiriusValidationProvider.java:75)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.sirius.diagram.ui.internal.providers.SiriusValidationProvider.runWithConstraints(SiriusValidationProvider.java:84)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.runValidation(ValidateAction.java:155)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction$1.run(ValidateAction.java:112)
	at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:71)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.lambda$0(WorkspaceModifyOperation.java:110)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:131)
	at org.eclipse.sirius.diagram.ui.part.ValidateAction.run(ValidateAction.java:114)
	at org.eclipse.sirius.diagram.ui.tools.internal.commands.ValidateDiagramCommand.execute(ValidateDiagramCommand.java:43)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
	at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:319)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:253)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:438)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:449)
	at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:475)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4213)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4030)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3630)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1158)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1047)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1447)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1420)

Re: Validating all diagrams in a session [message #1850395 is a reply to message #1850369] Tue, 01 March 2022 09:40 Go to previous messageGo to next message
Ali AKAR is currently offline Ali AKARFriend
Messages: 31
Registered: July 2009
Member
Hi Simon,

The ValidateAction you are using is to be used on an opened editor and it will create markers for elements in the editor.
I you need to run native EMF validation and to get a status, you can use this code:

IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
validator.setIncludeLiveConstraints(true);
IStatus status = validator.validate(eObjectToValidate);

Regards,
Ali
Re: Validating all diagrams in a session [message #1850422 is a reply to message #1850395] Wed, 02 March 2022 13:39 Go to previous messageGo to next message
Simon Tulia is currently offline Simon TuliaFriend
Messages: 14
Registered: January 2022
Junior Member
Hello Ali,

Thanks for your reply. I did not know so much about EMF validation and IStatus, I will look at this.

Btw, I found a way to validate all diagrams. For the future users, I am trying to tell how to do that. To overcome the "Cannot activate read/write transaction in read-only transaction context" exception, I ran
DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor());
command via using TransactionalEditingDomain class. During the validation of a diagram, if I found any problem, then I stopped traversing diagrams. I am sending a short version of the related code as a service function. As well, I close the diagrams after the validation if they have not been opened yet.

Lastly, if I call this function under a "validation" operation that is defined in .odesign file, then I encounter an exception that I could not figure out yet. However, there is no problem if I call it under an "operation action" menu.

public static boolean validateAllDiagrams(EObject self) {
    markerControl = false;
    HashSet<ISiriusEditor> openedEditorSet = new HashSet<ISiriusEditor>();

    Session session = SessionManager.INSTANCE.getSession(self);
    String sessionPath = session.getSessionResource().getURI().toPlatformString(true);
    TreeIterator<EObject> allTree = self.eAllContents();

    for(ISiriusEditor e: SessionUIManager.INSTANCE.getUISession(session).getSiriusEditors()) {
        if(e instanceof DDiagramEditor)
            openedEditorSet.add(e);
        }
    }

    IPath path = new Path(sessionPath);
    IFile repFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);

    while(allTree.hasNext()) {
        EObject i = allTree.next();
        Collection<DRepresentation> representationList = DialectManager.INSTANCE.getRepresentations(i, session);

        for(DRepresentation dr: representationList) {
            if(dr instanceof DDiagram) {
                if(!dr.getName().equals("TitleOfMyCurrentDiagram")) {
                    TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(i);
                    RecordingCommand r = new RecordingCommand(domain) {
                        @Override
                        protected void doExecute() {
                            IEditorPart editorPart = DialectUIManager.INSTANCE.openEditor(session, dr, new NullProgressMonitor());
                            DialectEditor de = (DialectEditor) editorPart;
                            de.validateRepresentation();

                            //	 instead of calling validateRepresentation function, below code works too.
                            // WorkbenchPartDescriptor workbenchPartDescriptor = new WorkbenchPartDescriptor(editorPart.getSite().getId(), editorPart.getClass(), editorPart.getSite().getPage());
                            // ValidateAction va = new ValidateAction(workbenchPartDescriptor);
                            // va.run();

                            try {
                                IMarker arr[] = repFile.findMarkers(IMarker.MARKER, true, IResource.DEPTH_INFINITE);
                                if(arr.length > 0)
                                    markerControl = true;
                            } catch (CoreException e) {
                                e.printStackTrace();
                            }

                            if(!markerControl){
                                if(!openedEditorSet.contains(editorPart)){
                                    DialectUIManager.INSTANCE.closeEditor(editorPart, false);
                                }
                            }
                        }
                    };

                    r.execute();
                    if(markerControl == true){
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

[Updated on: Wed, 02 March 2022 13:41]

Report message to a moderator

Re: Validating all diagrams in a session [message #1853873 is a reply to message #1850395] Wed, 20 July 2022 15:45 Go to previous message
Leonardo  Jones is currently offline Leonardo JonesFriend
Messages: 21
Registered: November 2021
Junior Member
Hi Ali,
I used your code and successfully got the IStatus, Thanks a lot!
Would you please give more guidance on how to deal with markers? My current code has problems: 1. error item(please see the image) is not removed after fix model and re-validate; 2. location is unknown so can not positioning element in diagram; 3. there is no markers in diagram.
Thanks again!

IStatus status = validator.validate(dNode);
MarkerUtil.createMarkers(status);
MarkerUtil.updateMarkers(status);



index.php/fa/42326/0/
  • Attachment: 123.PNG
    (Size: 6.04KB, Downloaded 297 times)

[Updated on: Wed, 20 July 2022 22:51]

Report message to a moderator

Previous Topic:Propertiesview of sirius-web showing elements of other documents in the same project
Next Topic:Validation only FAST and NORMAL
Goto Forum:
  


Current Time: Fri Nov 01 23:19:37 GMT 2024

Powered by FUDForum. Page generated in 0.03429 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top