From 5e702879e0ee3f352b5c88625fe05e1bf50f8889 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Tue, 20 Dec 2016 14:13:57 +0200 Subject: [PATCH] Show modelled STS tests in model browser in execution order refs #6890 Change-Id: Ib86a41bb738cf9fab476ce062811deeeccc3f317 --- .../graph.tg | Bin 5545 -> 5689 bytes .../graph/TestsUI.pgraph | 7 ++ .../modelled/ui/ontology/TestsUIResource.java | 3 + .../META-INF/MANIFEST.MF | 3 +- .../adapters.xml | 10 ++ .../tests/modelled/ui/STSSuiteSorterRule.java | 101 ++++++++++++++++++ 6 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 bundles/org.simantics.tests.modelled.ui/adapters.xml create mode 100644 bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/STSSuiteSorterRule.java diff --git a/bundles/org.simantics.tests.modelled.ui.ontology/graph.tg b/bundles/org.simantics.tests.modelled.ui.ontology/graph.tg index 862131139dfd500072221ac32ba7b194cd28064c..7935f8a67dbcc34681cf0040100c7ae759666b6d 100644 GIT binary patch literal 5689 zcmb_g3s6+o8D@FzE}$TSQHicbtwvo?g2fjg4`Jmg4d`f?N4Ee+ z;wuJUR?Ve)0$M;*bu+LWDby??89`j?D$PTtUQaYk`6oQQ!s`tT@C)}S%__?g9%%C! zSLS>w!S7Mr11uwbil6ec`2AkyG9R)Swh?BBr{6Qest1&S+DuMH!OS(XMR5neeFPEA zjE$R$Z{Y)|6(ga^WV0FH+S+Q@wPuAT#;M!A{zkGeLuIl$nw3U%=JXl%nFL3GGn>mj zjf^G`$*f{Zye`$Pc^bLh_rXS5bf zA4)XJw181dE=_r(*WX6IW0@{C$M0>`sl#Y#)&+>RfgT&<&>bG9JLpnf4vca> zV-pJ%oyQ@2zt#}sli*`&T3_a(lfyK|B$2}sO%Ez=9T_B#GNvC+dN!UxT06Ai2@iKo zfzlpLuBEg(Rn(V+QyCdWBp>=x79##(vr+@qQZw0#)oun;Bdy0WW)g$)yzXGLr%1(=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;vyP|N6UaC#X3gj{MTR<2m&m^f-dm!4OdgbO7R2 zP{0&nbp9Z#LxL?kks&13OCb_WkY}=`w0W{ov!cjpD@zb!q#IAVXm``ej&ezbLabz=32 z(DO4gUYhvP(HK|k`^UQfxYy)=>rW+hH&b?+HwG_#b?)uq7Td{!mSxs0`y!GH<|Now zU3~gfX59<#HDqUeX*HdDFE#u0{BJ_8pSC59eb>JpgCf;Ql2Ir0&sHiwciZWiY;xr~ zS-=1eDmLs=q>f`u2K}`r{n19J&wy@k#(!sS)nyNAb~>c6bEBPaZsNp75oWUp7Q_^% zpVf>?5=ORZS+==!cyVUgCQT-fRS#FY9O`ksrT@bC0jqBtoz9fQ`jo6ihW0-` C^n?ch diff --git a/bundles/org.simantics.tests.modelled.ui.ontology/graph/TestsUI.pgraph b/bundles/org.simantics.tests.modelled.ui.ontology/graph/TestsUI.pgraph index b51213dc8..ecebcf8fa 100644 --- a/bundles/org.simantics.tests.modelled.ui.ontology/graph/TestsUI.pgraph +++ b/bundles/org.simantics.tests.modelled.ui.ontology/graph/TestsUI.pgraph @@ -33,6 +33,13 @@ MBC @VP.namedRelationChildRule TestsUI.Contributions.STSTests L0.Entity L0.ConsistsOf TESTS.STSTest @VP.namedConstantImageRule TestsUI.Contributions.TestImage TESTS.STSTest TestsUI.testImage +MBC + VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution + VP.VisualsContribution.HasNodeType TESTS.STSSuite + VP.VisualsContribution.HasRule MBC.STSSuiteSorterRule + +MBC.STSSuiteSorterRule : VP.SorterRule + MAC = TestsUI.ModelingActionContext : VP.BrowseContext VP.BrowseContext.IsIncludedIn PROJECT.ProjectActionContext diff --git a/bundles/org.simantics.tests.modelled.ui.ontology/src/org/simantics/tests/modelled/ui/ontology/TestsUIResource.java b/bundles/org.simantics.tests.modelled.ui.ontology/src/org/simantics/tests/modelled/ui/ontology/TestsUIResource.java index 897d42c9d..752d44620 100644 --- a/bundles/org.simantics.tests.modelled.ui.ontology/src/org/simantics/tests/modelled/ui/ontology/TestsUIResource.java +++ b/bundles/org.simantics.tests.modelled.ui.ontology/src/org/simantics/tests/modelled/ui/ontology/TestsUIResource.java @@ -11,6 +11,7 @@ import org.simantics.db.service.QueryControl; public class TestsUIResource { public final Resource BrowseContext; + public final Resource BrowseContext_STSSuiteSorterRule; public final Resource Contributions; public final Resource Contributions_NewSTSSuite; public final Resource Contributions_NewSTSTest; @@ -29,6 +30,7 @@ public class TestsUIResource { public static class URIs { public static final String BrowseContext = "http://www.simantics.org/TestsUI-1.0/BrowseContext"; + public static final String BrowseContext_STSSuiteSorterRule = "http://www.simantics.org/TestsUI-1.0/BrowseContext/STSSuiteSorterRule"; public static final String Contributions = "http://www.simantics.org/TestsUI-1.0/Contributions"; public static final String Contributions_NewSTSSuite = "http://www.simantics.org/TestsUI-1.0/Contributions/NewSTSSuite"; public static final String Contributions_NewSTSTest = "http://www.simantics.org/TestsUI-1.0/Contributions/NewSTSTest"; @@ -57,6 +59,7 @@ public class TestsUIResource { public TestsUIResource(ReadGraph graph) { BrowseContext = getResourceOrNull(graph, URIs.BrowseContext); + BrowseContext_STSSuiteSorterRule = getResourceOrNull(graph, URIs.BrowseContext_STSSuiteSorterRule); Contributions = getResourceOrNull(graph, URIs.Contributions); Contributions_NewSTSSuite = getResourceOrNull(graph, URIs.Contributions_NewSTSSuite); Contributions_NewSTSTest = getResourceOrNull(graph, URIs.Contributions_NewSTSTest); diff --git a/bundles/org.simantics.tests.modelled.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.tests.modelled.ui/META-INF/MANIFEST.MF index 0e787d233..776eea39e 100644 --- a/bundles/org.simantics.tests.modelled.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.tests.modelled.ui/META-INF/MANIFEST.MF @@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui, org.simantics.tests.modelled.ui.ontology;bundle-version="1.0.0", org.simantics.tests.modelled;bundle-version="1.0.0", org.eclipse.e4.ui.model.workbench, - org.simantics.scl.osgi + org.simantics.scl.osgi, + org.simantics.browsing.ui.model Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Vendor: Semantum Oy diff --git a/bundles/org.simantics.tests.modelled.ui/adapters.xml b/bundles/org.simantics.tests.modelled.ui/adapters.xml new file mode 100644 index 000000000..d68f46686 --- /dev/null +++ b/bundles/org.simantics.tests.modelled.ui/adapters.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/STSSuiteSorterRule.java b/bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/STSSuiteSorterRule.java new file mode 100644 index 000000000..bdb55b6a2 --- /dev/null +++ b/bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/STSSuiteSorterRule.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.tests.modelled.ui; + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import org.simantics.browsing.ui.BuiltinKeys; +import org.simantics.browsing.ui.NodeContext; +import org.simantics.browsing.ui.model.browsecontexts.BrowseContext; +import org.simantics.browsing.ui.model.sorters.Sorter; +import org.simantics.browsing.ui.model.sorters.SorterRule; +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.RuntimeDatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.tests.modelled.ontology.TestsResource; +import org.simantics.utils.datastructures.Pair; +import org.simantics.utils.strings.AlphanumComparator; + +public class STSSuiteSorterRule implements SorterRule, Sorter { + + @Override + public boolean isCompatible(Class contentType) { + return contentType.equals(Resource.class); + } + + @Override + public Sorter getSorter(ReadGraph graph, Object content) throws DatabaseException { + return this; + } + + @Override + public void sort(ReadGraph graph, BrowseContext context, List nodes) throws DatabaseException + { + try { + STSTestComparator stc = new STSTestComparator(); + stc.graph = graph; + Collections.sort(nodes, stc); + } catch (RuntimeDatabaseException e) { + if (e.getCause()!=null && e.getCause() instanceof DatabaseException) throw (DatabaseException) e.getCause(); + throw e; + } + } + + static class STSTestQuery extends ResourceRead> { + + public STSTestQuery(Resource resource) { + super(resource); + } + + @Override + public Pair perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + TestsResource TESTS = TestsResource.getInstance(graph); + + String name = graph.getRelatedValue2(resource, L0.HasName, Bindings.STRING); + Integer priority = graph.getRelatedValue2(resource, TESTS.STSTest_executionPriority, Bindings.INTEGER); + + return new Pair(priority, name); + } + + } + + static class STSTestComparator implements Comparator { + ReadGraph graph; + + @Override + public int compare(NodeContext nc1, NodeContext nc2) { + Resource r1 = (Resource) nc1.getConstant(BuiltinKeys.INPUT); + Resource r2 = (Resource) nc2.getConstant(BuiltinKeys.INPUT); + + try { + Pair test1 = graph.sync(new STSTestQuery(r1)); + Pair test2 = graph.sync(new STSTestQuery(r2)); + + if (test1.first < test2.first) + return -1; + else if (test1.first > test2.first) + return 1; + else return AlphanumComparator.COMPARATOR.compare(test1.second, test2.second); + + } catch (DatabaseException e) { + throw new RuntimeDatabaseException(e); + } + } + } +} -- 2.47.1