From 06b8d15b931929743ddc4a90b4f057552b09c2b6 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Wed, 17 Jun 2020 15:56:45 +0300 Subject: [PATCH] Listen to changes in page settings Also enabled the setting of KEY_DISPLAY_PAGE hint which was for some reason disabled. Change-Id: I8f7136adf96e806bde5aa7c99dff8ce438ba1c80 --- .../ui/sg/DiagramSceneGraphProvider.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java index 1db2ba151..ca6d6d04c 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java @@ -26,6 +26,7 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.NoSingleResultException; import org.simantics.db.exception.ServiceException; import org.simantics.db.management.ISessionContext; +import org.simantics.db.procedure.Listener; import org.simantics.db.request.Read; import org.simantics.diagram.adapter.DefaultConnectionClassFactory; import org.simantics.diagram.adapter.FlagClassFactory; @@ -97,6 +98,7 @@ import org.simantics.utils.page.PageDesc; import org.simantics.utils.page.PageOrientation; import org.simantics.utils.threads.AWTThread; import org.simantics.utils.threads.IThreadWorkQueue; +import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.ErrorLogger; @@ -288,6 +290,35 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi DiagramDesc diagramDesc = Simantics.getSession().syncRequest(DiagramRequests.getDiagramDesc(diagramResource)); if (diagramDesc != null) setDiagramDesc(ctx, diagramDesc); + + // Create a listener to react to page setting changes. + Simantics.getSession().asyncRequest(DiagramRequests.getDiagramDesc(diagramResource), new Listener() { + + @Override + public void execute(DiagramDesc result) { + if (result != null && ctx != null) { + ThreadUtils.asyncExec(ctx.getThreadAccess(), new Runnable() { + @Override + public void run() { + if (ctx != null) { + setDiagramDesc(ctx, result); + } + } + }); + } + } + + @Override + public void exception(Throwable t) { + ErrorLogger.defaultLogError(t); + } + + @Override + public boolean isDisposed() { + return ctx == null; + } + + }); } catch (DatabaseException e) { ErrorLogger.defaultLogError(e); } @@ -296,7 +327,7 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi protected void setDiagramDesc(ICanvasContext ctx, DiagramDesc diagramDesc) { IHintContext hints = ctx.getDefaultHintContext(); hints.setHint(Hints.KEY_PAGE_DESC, diagramDesc.getPageDesc()); - //hints.setHint(Hints.KEY_DISPLAY_PAGE, diagramDesc.isPageBordersVisible()); + hints.setHint(Hints.KEY_DISPLAY_PAGE, diagramDesc.isPageBordersVisible()); hints.setHint(Hints.KEY_DISPLAY_MARGINS, diagramDesc.isMarginsVisible()); } -- 2.47.1