X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.tests.modelled.ui%2Fsrc%2Forg%2Fsimantics%2Ftests%2Fmodelled%2Fui%2FSTSSuiteSorterRule.java;fp=bundles%2Forg.simantics.tests.modelled.ui%2Fsrc%2Forg%2Fsimantics%2Ftests%2Fmodelled%2Fui%2FSTSSuiteSorterRule.java;h=b29545df4e44384fed33698f3d87864a2b43b755;hb=013df68afa182f2c8d0b8a662437e3bcb889d61d;hp=78de04dc48f1edf6765566b4f17f24b119d023c6;hpb=7704490bfa8dc36625615df61cfe18d01d86ff18;p=simantics%2Fplatform.git 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 index 78de04dc4..b29545df4 100644 --- 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 @@ -33,69 +33,72 @@ 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)); + @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); + if(graph.isInstanceOf(resource, TESTS.STSTest)) { + Integer priority = graph.getRelatedValue2(resource, TESTS.STSTest_executionPriority, Bindings.INTEGER); + return new Pair(priority, name); + } else { + return new Pair(0, 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); - } - } - } + + } catch (DatabaseException e) { + throw new RuntimeDatabaseException(e); + } + } + } }