public void Layout()
        {
            if (Controller == null || Controller.GetVisibleShapes().Any() == false)
            {
                // No visible shapes.
                LayoutFinished.RaiseEvent(this);
                return;
            }

            Cursor = Cursors.Wait;

            // The UpdateLayout() call is important, as it causes the sizes of the
            // shapes to be calculated. These sizes are needed for the layout algorithm.
            UpdateLayout();

            InvalidateVisual();

            var layout = new DiagramLayout();

            layout.CalculateLayout(Controller.GetVisibleShapes(), Controller.GetVisibleConnections(), ActualWidth, ActualHeight);
            layout.LayoutGraph();
            Surface.TidyConnections();

            CalculateZoom();

            Cursor = Cursors.Arrow;
            LayoutFinished.RaiseEvent(this);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getProcessDiagramLayoutWithAuthenticatedTenant()
        public virtual void getProcessDiagramLayoutWithAuthenticatedTenant()
        {
            identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));

            DiagramLayout diagramLayout = repositoryService.getProcessDiagramLayout(processDefinitionId);

            assertThat(diagramLayout, notNullValue());
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getProcessDiagramLayoutDisabledTenantCheck()
        public virtual void getProcessDiagramLayoutDisabledTenantCheck()
        {
            processEngineConfiguration.TenantCheckEnabled = false;
            identityService.setAuthentication("user", null, null);

            DiagramLayout diagramLayout = repositoryService.getProcessDiagramLayout(processDefinitionId);

            assertThat(diagramLayout, notNullValue());
        }
        public virtual void getProcessDiagramLayoutDisabledTenantCheck()
        {
            processEngineConfiguration.SetTenantCheckEnabled(false);
            identityService.SetAuthentication("user", null, null);

            DiagramLayout diagramLayout = repositoryService.GetProcessDiagramLayout(processDefinitionId);

            Assert.That(diagramLayout != null);
        }
        public virtual void getProcessDiagramLayoutWithAuthenticatedTenant()
        {
            identityService.SetAuthentication("user", null, new List <string>()
            {
                TENANT_ONE
            });

            DiagramLayout diagramLayout = repositoryService.GetProcessDiagramLayout(processDefinitionId);

            Assert.That(diagramLayout != null);
        }
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private void AssertLayoutCorrect(org.camunda.bpm.Engine.Repository.DiagramLayout processDiagramLayout) throws java.io.IOException
        private void AssertLayoutCorrect(DiagramLayout processDiagramLayout)
        {
            string html = generateHtmlCode(imageFileName, processDiagramLayout, highlightedActivityId);

            FileInfo htmlFile = new FileInfo("src/test/resources/resources/api/repository/diagram/" + imageFileName + ".html");

            if (OVERWRITE_EXPECTED_HTML_FILES)
            {
                //FileUtils.WriteStringToFile(htmlFile, html);
                //fail("The Assertions of this test only work if ProcessDiagramRetrievalTest#OVERWRITE_EXPECTED_HTML_FILES is set to false.");
            }
            //AssertEquals(FileUtils.ReadFileToString(htmlFile).Replace("\r", ""), html); // remove carriage returns in case the files have been fetched via Git on Windows
        }
Example #7
0
        public virtual void testGetProcessDiagramLayout()
        {
            // given
            string processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).Id;

            createGrantAuthorization(Resources.ProcessDefinition, ONE_TASK_PROCESS_KEY, userId, Permissions.Read);

            // when
            DiagramLayout diagramLayout = repositoryService.GetProcessDiagramLayout(processDefinitionId);

            // then
            // no process diagram deployed
            Assert.IsNull(diagramLayout);
        }
Example #8
0
 internal void AddUpdateLinks(DiagramLayout layout, Action update)
 {
     if (!this.Animated)
     {
         return;
     }
     // just for top-level layout, not for groups
     if (layout.Group == null)
     {
         if (this.UpdateLinksActions == null)
         {
             this.UpdateLinksActions = new List <Action>();
         }
         this.UpdateLinksActions.Add(update);
     }
 }
        private static string generateHtmlCode(string imageUrl, DiagramLayout processDiagramLayout, string highlightedActivityId)
        {
            StringBuilder html = new StringBuilder();

            html.Append("<!DOCTYPE html>\n");
            html.Append("<html>\n");
            html.Append("  <head>\n");
            html.Append("    <style type=\"text/css\"><!--\n");
            html.Append("      .BPMNElement {\n");
            html.Append("        position: absolute;\n");
            html.Append("        border: 2px dashed lightBlue;\n");
            html.Append("        border-radius: 5px; -moz-border-radius: 5px;\n");
            html.Append("      }\n");
            if (!string.ReferenceEquals(highlightedActivityId, null) && highlightedActivityId.Length > 0)
            {
                html.Append("      #" + highlightedActivityId + " {border: 2px solid red;}\n");
            }
            html.Append("    --></style>");
            html.Append("  </head>\n");
            html.Append("  <body>\n");
            html.Append("    <div style=\"position: relative\">\n");
            html.Append("      <img src=\"" + imageUrl + "\" />\n");

            IList <DiagramNode> nodes = new List <DiagramNode>(processDiagramLayout.Nodes);

            // sort the nodes according to their ID property.
            // nodes.Sort(new DiagramNodeComparator());
            foreach (DiagramNode node in nodes)
            {
                html.Append("      <div");
                html.Append(" class=\"BPMNElement\"");
                html.Append(" id=\"" + node.Id + "\"");
                html.Append(" style=\"");
                html.Append(" left: " + (int)(node.X - 2) + "px;");
                html.Append(" top: " + (int)(node.Y - 2) + "px;");
                html.Append(" width: " + node.Width.Value + "px;");
                html.Append(" height: " + node.Height.Value + "px;\"></div>\n");
            }
            html.Append("    </div>\n");
            html.Append("  </body>\n");
            html.Append("</html>");
            return(html.ToString());
        }
Example #10
0
 /// <summary>
 /// This override replaces the default <see cref="Diagram.Layout"/> with a <see cref="GridLayout"/>
 /// that executes under <see cref="DiagramLayout.Conditions"/> that include <see cref="LayoutChange.ViewportSizeChanged"/>.
 /// </summary>
 public override void OnApplyTemplate()
 {
     // use a different default Layout than what the Diagram constructor might set
     if (this.Layout == null || this.Layout.GetType() == typeof(Northwoods.GoXam.Layout.DiagramLayout))
     {
         var layout = new GridLayout();
         layout.Conditions = LayoutChange.Standard | LayoutChange.ViewportSizeChanged;
         this.Layout       = layout;
     }
     else
     {
         DiagramLayout layout = this.Layout as DiagramLayout;
         if (layout != null)
         {
             layout.Conditions |= LayoutChange.ViewportSizeChanged;
         }
     }
     base.OnApplyTemplate();
 }