From: Tuukka Lehtonen Date: Tue, 6 Sep 2016 11:45:06 +0000 (+0300) Subject: Merge "Some Acorn improvements" X-Git-Tag: v1.25.0~135 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=d77257f045bacb676d276fe3a702e43e3a4eada3;hp=80907a9c5480a15ee32db2f7e7acec3dd1b6d9d5 Merge "Some Acorn improvements" --- diff --git a/bundles/org.simantics.acorn/META-INF/MANIFEST.MF b/bundles/org.simantics.acorn/META-INF/MANIFEST.MF index 24f576bdc..9152acafd 100644 --- a/bundles/org.simantics.acorn/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.acorn/META-INF/MANIFEST.MF @@ -4,17 +4,13 @@ Bundle-Name: Acorn Database for Simantics Bundle-SymbolicName: org.simantics.acorn Bundle-Version: 1.1.2.qualifier Bundle-Vendor: Semantum Oy -Require-Bundle: org.apache.log4j;visibility:=reexport, - org.simantics.db;bundle-version="0.8.0";visibility:=reexport, - org.simantics.db.common;bundle-version="0.8.0";visibility:=reexport, - gnu.trove3;bundle-version="3.0.0", +Require-Bundle: gnu.trove3;bundle-version="3.0.0", gnu.trove2;bundle-version="2.0.4", org.simantics.db.impl;bundle-version="0.8.0", org.simantics.db.server;bundle-version="1.0.0", org.simantics.compressions;bundle-version="1.0.0", org.simantics.backup, org.eclipse.core.runtime;bundle-version="3.11.1", - org.simantics.fastlz;bundle-version="1.2.1", org.simantics.db.procore Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy diff --git a/bundles/org.simantics.acorn/OSGI-INF/component.xml b/bundles/org.simantics.acorn/OSGI-INF/component.xml index 75dd81fd9..5b88ac3c0 100644 --- a/bundles/org.simantics.acorn/OSGI-INF/component.xml +++ b/bundles/org.simantics.acorn/OSGI-INF/component.xml @@ -1,6 +1,6 @@ - + diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java b/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java index 69aea11ee..dd7ae02a0 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java @@ -10,8 +10,8 @@ import org.simantics.databoard.binding.error.BindingException; import org.simantics.databoard.util.Bean; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.PossibleModel; import org.simantics.history.HistoryException; import org.simantics.history.HistorySamplerItem; import org.simantics.history.ItemManager; @@ -42,7 +42,7 @@ public final class Charts { try { - Resource model = graph.syncRequest(new PossibleModel(subscriptionItem)); + Resource model = graph.syncRequest(new PossibleIndexRoot(subscriptionItem)); if ( model == null ) { throw new DatabaseException("There is no model for " + subscriptionItem); } diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/util/URIStringUtils.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/util/URIStringUtils.java index dde498a2c..1cd658ba9 100644 --- a/bundles/org.simantics.databoard/src/org/simantics/databoard/util/URIStringUtils.java +++ b/bundles/org.simantics.databoard/src/org/simantics/databoard/util/URIStringUtils.java @@ -335,6 +335,50 @@ public final class URIStringUtils { final private static Charset UTF8 = Charset.forName("UTF-8"); final private static Charset ASCII = Charset.forName("US-ASCII"); + /* + * RFC 3986 section 2.2 Reserved Characters (January 2005) + * !*'();:@&=+$,/?#[] + */ + private static boolean[] UNESCAPED_US_ASCII_CHARS = new boolean[128]; + + static { + for(char ch='A';ch <= 'Z';++ch) + UNESCAPED_US_ASCII_CHARS[ch] = true; + for(char ch='a';ch <= 'z';++ch) + UNESCAPED_US_ASCII_CHARS[ch] = true; + for(char ch='0';ch <= '9';++ch) + UNESCAPED_US_ASCII_CHARS[ch] = true; + UNESCAPED_US_ASCII_CHARS[';'] = true; + UNESCAPED_US_ASCII_CHARS['?'] = true; + UNESCAPED_US_ASCII_CHARS[':'] = true; + UNESCAPED_US_ASCII_CHARS['@'] = true; + UNESCAPED_US_ASCII_CHARS['='] = true; + UNESCAPED_US_ASCII_CHARS['+'] = true; + UNESCAPED_US_ASCII_CHARS['$'] = true; + UNESCAPED_US_ASCII_CHARS['.'] = true; + UNESCAPED_US_ASCII_CHARS[','] = true; + UNESCAPED_US_ASCII_CHARS['-'] = true; + UNESCAPED_US_ASCII_CHARS['_'] = true; + UNESCAPED_US_ASCII_CHARS['!'] = true; + UNESCAPED_US_ASCII_CHARS['~'] = true; + UNESCAPED_US_ASCII_CHARS['*'] = true; + UNESCAPED_US_ASCII_CHARS['\''] = true; + UNESCAPED_US_ASCII_CHARS['('] = true; + UNESCAPED_US_ASCII_CHARS[')'] = true; + UNESCAPED_US_ASCII_CHARS['['] = true; + UNESCAPED_US_ASCII_CHARS[']'] = true; + } + + private static boolean needsEscaping(String unicode) { + int len = unicode.length(); + for (int i = 0; i < len; ++i) { + char ch = unicode.charAt(i); + if (ch >= 128 || !UNESCAPED_US_ASCII_CHARS[ch]) + return true; + } + return false; + } + /* Copied and modified from Jena 2.4 com.hp.hpl.jena.util.URIref */ private static String encode(String unicode) { boolean needsEscapes = needsEscaping(unicode); @@ -346,17 +390,13 @@ public final class URIStringUtils { int in = 0; int out = 0; while (in < utf8.length) { - switch (utf8[in]) { - case (byte)'a': case (byte)'b': case (byte)'c': case (byte)'d': case (byte)'e': case (byte)'f': case (byte)'g': case (byte)'h': case (byte)'i': case (byte)'j': case (byte)'k': case (byte)'l': case (byte)'m': case (byte)'n': case (byte)'o': case (byte)'p': case (byte)'q': case (byte)'r': case (byte)'s': case (byte)'t': case (byte)'u': case (byte)'v': case (byte)'w': case (byte)'x': case (byte)'y': case (byte)'z': - case (byte)'A': case (byte)'B': case (byte)'C': case (byte)'D': case (byte)'E': case (byte)'F': case (byte)'G': case (byte)'H': case (byte)'I': case (byte)'J': case (byte)'K': case (byte)'L': case (byte)'M': case (byte)'N': case (byte)'O': case (byte)'P': case (byte)'Q': case (byte)'R': case (byte)'S': case (byte)'T': case (byte)'U': case (byte)'V': case (byte)'W': case (byte)'X': case (byte)'Y': case (byte)'Z': - case (byte)'0': case (byte)'1': case (byte)'2': case (byte)'3': case (byte)'4': case (byte)'5': case (byte)'6': case (byte)'7': case (byte)'8': case (byte)'9': - case (byte)';': case (byte)'?': case (byte)':': case (byte)'@': case (byte)'=': case (byte)'+': case (byte)'$': case (byte)',': - case (byte)'-': case (byte)'_': case (byte)'.': case (byte)'!': case (byte)'~': case (byte)'*': case (byte)'\'': case (byte)'(': case (byte)')': - case (byte)'[': case (byte)']': - rsltAscii[out] = utf8[in]; - out++; - in++; - break; + byte inCh = utf8[in]; + if (inCh >= 0 && inCh < 128 && UNESCAPED_US_ASCII_CHARS[inCh]) { + rsltAscii[out] = inCh; + out++; + in++; + } else { + switch (inCh) { case (byte)' ': rsltAscii[out++] = (byte) '%'; rsltAscii[out++] = '2'; @@ -366,7 +406,7 @@ public final class URIStringUtils { case (byte) '%': // [lehtonen] NOTE: all input needs to be escaped, i.e. "%01" should result in "%2501", not "%01". // escape+unescape is a bijection, not an idempotent operation. - // Fall through to to escape '%' as '%25' + // Fall through to escape '%' as '%25' case (byte) '#': case (byte) '/': // Fall through to escape '/' @@ -376,52 +416,17 @@ public final class URIStringUtils { default: rsltAscii[out++] = (byte) '%'; // Get rid of sign ... - int c = (utf8[in]) & 255; + int c = (inCh) & 255; rsltAscii[out++] = hexEncode(c / 16); rsltAscii[out++] = hexEncode(c % 16); in++; break; + } } } return new String(rsltAscii, 0, out, ASCII); } - /* - * RFC 3986 section 2.2 Reserved Characters (January 2005) - * !*'();:@&=+$,/?#[] - */ - private static boolean needsEscaping(String unicode) { - int len = unicode.length(); - for (int i = 0; i < len; ++i) { - switch (unicode.charAt(i)) { - case (byte)'!': - case (byte)'*': - case (byte)'\'': - case (byte)'(': - case (byte)')': - case (byte)';': - case (byte)':': - case (byte)'@': - case (byte)'=': - case (byte)'+': - case (byte)'$': - case (byte)',': - case (byte)'?': - case (byte)'~': - case (byte)'[': - case (byte)']': - break; - case (byte)' ': - case (byte) '#': - case (byte) '%': - case (byte) '/': - case (byte)'&': - return true; - } - } - return false; - } - private static boolean needsUnescaping(String unicode) { return unicode.indexOf('%') > -1; } @@ -513,6 +518,8 @@ public final class URIStringUtils { testEscape("%", "%25"); testEscape("%01", "%2501"); testEscape("%GG", "%25GG"); + testEscape("säätö venttiili", "s%C3%A4%C3%A4t%C3%B6%20venttiili"); + testEscape("säätö", "s%C3%A4%C3%A4t%C3%B6"); } private static void testEscape(String unescaped, String expectedEscaped) { diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleActiveExperiment.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleActiveExperiment.java index 3db016d79..6caca12c5 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleActiveExperiment.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleActiveExperiment.java @@ -13,6 +13,7 @@ package org.simantics.db.layer0.request; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.common.request.ResourceRead; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; @@ -27,7 +28,7 @@ public class PossibleActiveExperiment extends ResourceRead { @Override public Resource perform(ReadGraph graph) throws DatabaseException { - Resource model = graph.sync(new PossibleModel(resource)); + Resource model = graph.sync(new PossibleIndexRoot(resource)); if(model == null) return null; Layer0 b = Layer0.getInstance(graph); diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessorState.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessorState.java index d4f0dbe01..de8a17c78 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessorState.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessorState.java @@ -16,6 +16,7 @@ public class DomainProcessorState { public TIntIntHashMap inverses = new TIntIntHashMap(); public TIntHashSet externals = new TIntHashSet(); public TIntIntHashMap ids = new TIntIntHashMap(100, 0.6f, -1, -1); + public TIntHashSet pending = new TIntHashSet(); public int statementCount; public int valueCount; diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java index 2636bb0d7..79f093748 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java @@ -248,7 +248,9 @@ public class ModelTransferableGraphSource implements TransferableGraphSource { int p = state.otherStatementsInput.readInt(); int o = state.otherStatementsInput.readInt(); if(!exclude) { - if(state.excludedShared.contains(o)) { + if(state.pending.contains(o)) { + System.err.println("excluding garbage statement " + s + " " + p + " " + o + ", object resource is garbage"); + } else if(state.excludedShared.contains(o)) { System.err.println("excluding shared " + s + " " + p + " " + o); } else { diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSourceRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSourceRequest.java index c61fdadcb..d7fe5c690 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSourceRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSourceRequest.java @@ -440,8 +440,10 @@ public class ModelTransferableGraphSourceRequest extends UniqueRead { public static String LOG_FILE = "transferableGraph.log"; diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java index 81e1e46e9..e323f4f8c 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/Variables.java @@ -26,13 +26,13 @@ import org.simantics.databoard.util.URIStringUtils; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; +import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.common.request.TernaryRead; import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.exception.MissingVariableException; import org.simantics.db.layer0.request.Model; import org.simantics.db.layer0.request.PossibleActiveVariableFromVariable; -import org.simantics.db.layer0.request.PossibleModel; import org.simantics.db.layer0.request.PossibleVariableIndexRoot; import org.simantics.db.layer0.request.PossibleVariableModel; import org.simantics.db.layer0.request.PropertyInfo; @@ -332,7 +332,7 @@ final public class Variables { public static Variable getPossibleConfigurationContext(ReadGraph graph, Resource resource) throws DatabaseException { SimulationResource SIMU = SimulationResource.getInstance(graph); - if (!graph.isInstanceOf(resource, SIMU.Model)) resource = graph.sync(new PossibleModel(resource)); + if (!graph.isInstanceOf(resource, SIMU.Model)) resource = graph.sync(new PossibleIndexRoot(resource)); if (resource == null) return null; Resource configurationResource = graph.getPossibleObject(resource, SIMU.HasConfiguration); @@ -343,7 +343,7 @@ final public class Variables { public static Variable getPossibleConfigurationContext(ReadGraph graph, Variable variable) throws DatabaseException { SimulationResource SIMU = SimulationResource.getInstance(graph); - Resource model = getPossibleModel(graph, variable); + Resource model = getPossibleIndexRoot(graph, variable); if (model == null) return null; Resource configurationResource = graph.getPossibleObject(model, SIMU.HasConfiguration); diff --git a/bundles/org.simantics.diagram.ontology/graph.tg b/bundles/org.simantics.diagram.ontology/graph.tg index 543a0a3e3..ab1473989 100644 Binary files a/bundles/org.simantics.diagram.ontology/graph.tg and b/bundles/org.simantics.diagram.ontology/graph.tg differ diff --git a/bundles/org.simantics.diagram.ontology/graph/DiagramScenegraph.pgraph b/bundles/org.simantics.diagram.ontology/graph/DiagramScenegraph.pgraph index 0a7cc33ff..364b539fa 100644 --- a/bundles/org.simantics.diagram.ontology/graph/DiagramScenegraph.pgraph +++ b/bundles/org.simantics.diagram.ontology/graph/DiagramScenegraph.pgraph @@ -12,6 +12,7 @@ DIA.Scenegraph.Node -- DIA.Scenegraph.Composite.transform --> G2D.Transform "Vector Double" DIA.Scenegraph.Component -- DIA.Scenegraph.AbstractText.color --> DATATYPES.RGB.Integer -- DIA.Scenegraph.AbstractText.font --> DATATYPES.Font -- DIA.Scenegraph.AbstractText.transform --> G2D.Transform "DoubleArray" + ==> "Vector Double" >-- DIA.Scenegraph.AbstractText.borderWidth --> L0.Value "Float" >-- DIA.Scenegraph.AbstractText.borderColor --> DATATYPES.RGB.Integer -- DIA.Scenegraph.SVGImage.document --> L0.Value "String" >-- DIA.Scenegraph.SVGImage.transform --> G2D.Transform "Vector Double" @L0.assert DIA.Scenegraph.SVGImage.transform [1,0,0,1,0,0] : G2D.Transform \ No newline at end of file diff --git a/bundles/org.simantics.document.server/scl/Document/All.scl b/bundles/org.simantics.document.server/scl/Document/All.scl index 53124fb46..3d63eaf6a 100644 --- a/bundles/org.simantics.document.server/scl/Document/All.scl +++ b/bundles/org.simantics.document.server/scl/Document/All.scl @@ -115,6 +115,8 @@ importJava "org.simantics.document.server.Functions" where @JavaName getPropertyValueCached propertyValueCached_ :: Variable -> String -> Binding a -> a + stateVariable :: Variable -> Variable + propertyValueCached :: Serializable a => Typeable a => Variable -> String -> a propertyValueCached var prop = propertyValueCached_ var prop binding diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java index 2fd422f5e..2ba85b733 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java @@ -185,6 +185,13 @@ public class Functions { return Variables.getVariable(graph, uri); } + public static Variable stateVariable(ReadGraph graph, Variable self) throws DatabaseException { + Variable session = graph.syncRequest(new ProxySessionRequest(self)); + if (session == null) + throw new DatabaseException("No state for " + self.getURI(graph)); + return session.getPossibleChild(graph, "__scl__"); + } + @SCLValue(type = "ReadGraph -> Resource -> Variable -> Variable") public static Variable state(ReadGraph graph, Resource converter, Variable context) throws DatabaseException { Variable session = graph.syncRequest(new ProxySessionRequest(context)); diff --git a/bundles/org.simantics.document/simantics-wiki-documents-default-model.css b/bundles/org.simantics.document/simantics-wiki-documents-default-model.css index 6fa388dae..47b66055e 100644 --- a/bundles/org.simantics.document/simantics-wiki-documents-default-model.css +++ b/bundles/org.simantics.document/simantics-wiki-documents-default-model.css @@ -15,7 +15,7 @@ div.description { font-family: "Times New Roman"; font-size: 1.5em; color: black; - margin-left: 10px; + margin-left: 0px; margin-bottom: 10px; margin-right: 0px; margin-top: 0px; @@ -27,7 +27,7 @@ p { font-size: 1.0em; color: black; margin-top: 10px; - margin-bottom: 10px; + margin-bottom: 15px; } /* Level 1 header */ @@ -35,17 +35,17 @@ h1 { font-family: "Times New Roman"; font-size: 1.6em; color: black; - margin-top: 16px; - margin-bottom: 2px; + margin-top: 16px; + margin-bottom: 2px; } /* Level 2 header */ h2 { font-family: "Times New Roman"; - font-size: 1.4em; + font-size: 1.4em; color: black; - margin-top: 14px; - margin-bottom: 2px; + margin-top: 14px; + margin-bottom: 2px; } /* Level 3 header */ @@ -53,8 +53,8 @@ h3 { font-family: "Times New Roman"; font-size: 1.2em; color: black; - margin-top: 12px; - margin-bottom: 2px; + margin-top: 12px; + margin-bottom: 2px; } /* Level 4 header */ @@ -62,8 +62,8 @@ h4 { font-family: "Times New Roman"; font-size: 1.0em; color: black; - margin-top: 10px; - margin-bottom: 2px; + margin-top: 10px; + margin-bottom: 2px; } /* Numbered list items */ @@ -84,23 +84,52 @@ ol li { margin-bottom: 1px; } +/* Links */ +a { + font-family: "Times New Roman"; + font-size: 1.0em; + margin-left: 2px; + margin-top: 1px; + margin-bottom: 1px; +} + /* Table items */ td div { font-family: "Times New Roman"; - font-size: 1.0em; + font-size: 0.6em; + line-height: 1.2; + padding: 2px; } /* Tables items */ table { + table-layout: auto; + width: auto; + margin-top: 10px; margin-bottom: 10px; + margin-left: 15px; + margin-right: 30px; + + border-collapse: collapse; + border: 0px solid black; + + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; } -/* Links */ -a { - font-family: "Times New Roman"; - font-size: 1.0em; - margin-left: 2px; - margin-top: 1px; - margin-bottom: 1px; +table div { + white-space: normal; +} + +th, td { + text-align: left; + border: 1px solid black; + padding: 2px; +} + +td div, th div { + border: none; } diff --git a/bundles/org.simantics.document/simantics-wiki-documents.css b/bundles/org.simantics.document/simantics-wiki-documents.css index 101e698c9..c28af5b17 100644 --- a/bundles/org.simantics.document/simantics-wiki-documents.css +++ b/bundles/org.simantics.document/simantics-wiki-documents.css @@ -37,18 +37,18 @@ div { } table { - border-collapse: collapse; - width: 100%; table-layout: fixed; + box-sizing: border-box; + width: 100%; + -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; + border: 0px; padding: 0px; - box-sizing: border-box; - } td { @@ -75,24 +75,23 @@ table th:first-child div { } table div { + height: auto; + width: auto; padding-left: 1px; border-right: 1px; border-left: 1px; - border-top: 1px; border-bottom: 1px; + margin-bottom: -1px; margin-left: -1px; border-style: solid; - text-overflow: ellipsis; overflow: hidden; + text-overflow: ellipsis; white-space: nowrap; - height: auto; - width: auto; page-break-inside: avoid; - box-sizing: border-box; - + box-sizing: border-box; } diff --git a/bundles/org.simantics.document/src/org/simantics/document/Exportable.java b/bundles/org.simantics.document/src/org/simantics/document/Exportable.java index 74a739352..637340b90 100644 --- a/bundles/org.simantics.document/src/org/simantics/document/Exportable.java +++ b/bundles/org.simantics.document/src/org/simantics/document/Exportable.java @@ -74,8 +74,7 @@ public class Exportable implements IExportable { this.settings = settings; MarkupParser markupParser = new MarkupParser(); - MediaWikiLanguage language = new MediaWikiLanguage(); - markupParser.setMarkupLanguage(language); + markupParser.setMarkupLanguage(new MediaWikiLanguage()); String html = markupParser.parseToHtml(wiki); String width = "width:" + (210-settings.marginLeft-settings.marginRight) + "mm;"; @@ -95,7 +94,7 @@ public class Exportable implements IExportable { html = html.replace("", "
"); html = html.replace("", "
"); html = html.replace("", ""); - html = html.replace("", ""); + html = html.replace("", "\n\n"); this.html = html; diff --git a/bundles/org.simantics.export.core/META-INF/MANIFEST.MF b/bundles/org.simantics.export.core/META-INF/MANIFEST.MF index a194cf133..eadcf7e08 100644 --- a/bundles/org.simantics.export.core/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.export.core/META-INF/MANIFEST.MF @@ -24,3 +24,5 @@ Export-Package: org.simantics.export.core, org.simantics.export.core.manager, org.simantics.export.core.pdf, org.simantics.export.core.util +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.simantics.export.core.internal.Activator diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/internal/Activator.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/internal/Activator.java new file mode 100644 index 000000000..e07fa5863 --- /dev/null +++ b/bundles/org.simantics.export.core/src/org/simantics/export/core/internal/Activator.java @@ -0,0 +1,28 @@ +package org.simantics.export.core.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * @author Tuukka Lehtonen + * @since 1.22.2 + */ +public class Activator implements BundleActivator { + + private static BundleContext context; + + public static BundleContext getContext() { + return context; + } + + @Override + public void start(BundleContext context) throws Exception { + Activator.context = context; + } + + @Override + public void stop(BundleContext context) throws Exception { + Activator.context = null; + } + +} diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ExportPdfWriter.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ExportPdfWriter.java index 7a490e642..6318e5de2 100644 --- a/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ExportPdfWriter.java +++ b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ExportPdfWriter.java @@ -399,6 +399,7 @@ public class ExportPdfWriter { this.pdfWriter = PdfWriter.getInstance(document, fos); this.pdfWriter.setPdfVersion(PdfWriter.PDF_VERSION_1_7); this.pdfWriter.setCompressionLevel( compressionLevel ); + this.pdfWriter.setPageEvent(new ServiceBasedPdfExportPageEvent()); this.document.open(); this.cb = this.pdfWriter.getDirectContent(); if (!this.document.newPage()) throw new ExportException("Failed to create new page."); diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/PdfExportPageEvent.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/PdfExportPageEvent.java new file mode 100644 index 000000000..60573fa11 --- /dev/null +++ b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/PdfExportPageEvent.java @@ -0,0 +1,9 @@ +package org.simantics.export.core.pdf; + +import com.lowagie.text.pdf.PdfPageEvent; + +/** + * @author Tuukka Lehtonen + */ +public interface PdfExportPageEvent extends PdfPageEvent { +} diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java new file mode 100644 index 000000000..c513654df --- /dev/null +++ b/bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ServiceBasedPdfExportPageEvent.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2016 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: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.export.core.pdf; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import org.simantics.Logger; +import org.simantics.export.core.internal.Activator; + +import com.lowagie.text.Document; +import com.lowagie.text.Paragraph; +import com.lowagie.text.Rectangle; +import com.lowagie.text.pdf.PdfPageEventHelper; +import com.lowagie.text.pdf.PdfWriter; + +/** + * @author Tuukka Lehtonen + * @since 1.22.2 + */ +public class ServiceBasedPdfExportPageEvent extends PdfPageEventHelper { + + Map events; + + public ServiceBasedPdfExportPageEvent() { + // Read all page event contributions from the OSGi service + events = collectEvents(); + } + + private static Map collectEvents() { + BundleContext context = Activator.getContext(); + Collection> serviceReferences; + try { + serviceReferences = context.getServiceReferences(PdfExportPageEvent.class, null); + } catch (InvalidSyntaxException e) { + e.printStackTrace(); + serviceReferences = Collections.emptyList(); + } + Map events = new HashMap<>(serviceReferences.size()); + for (ServiceReference reference : serviceReferences) { + PdfExportPageEvent event = context.getService(reference); + String eventName = event.toString(); + events.put(eventName, event); + } + return events; + } + + private void safeInvoke(String eventName, PdfExportPageEvent event, Consumer r) { + try { + r.accept(event); + } catch (Exception e) { + Logger.defaultLogError("Failed to invoke PdfExportPageEvent::" + eventName + " for " + event.toString(), e); + } + } + + @Override + public void onChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title) { + events.values().forEach(e -> safeInvoke("onChapter", e, ee -> ee.onChapter(writer, document, paragraphPosition, title))); + } + + @Override + public void onChapterEnd(PdfWriter writer, Document document, float position) { + events.values().forEach(e -> safeInvoke("onChapterEnd", e, ee -> ee.onChapterEnd(writer, document, position))); + } + + @Override + public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) { + events.values().forEach(e -> safeInvoke("onGenericTag", e, ee -> ee.onGenericTag(writer, document, rect, text))); + } + + @Override + public void onOpenDocument(PdfWriter writer, Document document) { + events.values().forEach(e -> safeInvoke("onOpenDocument", e, ee -> ee.onOpenDocument(writer, document))); + } + + @Override + public void onCloseDocument(PdfWriter writer, Document document) { + events.values().forEach(e -> safeInvoke("onCloseDocument", e, ee -> ee.onCloseDocument(writer, document))); + } + + @Override + public void onParagraph(PdfWriter writer, Document document, float paragraphPosition) { + events.values().forEach(e -> safeInvoke("onParagraph", e, ee -> ee.onParagraph(writer, document, paragraphPosition))); + } + + @Override + public void onParagraphEnd(PdfWriter writer, Document document, float paragraphPosition) { + events.values().forEach(e -> safeInvoke("onParagraphEnd", e, ee -> ee.onParagraphEnd(writer, document, paragraphPosition))); + } + + @Override + public void onSection(PdfWriter writer, Document document, float paragraphPosition, int depth, Paragraph title) { + events.values().forEach(e -> safeInvoke("onSection", e, ee -> ee.onSection(writer, document, paragraphPosition, depth, title))); + } + + @Override + public void onSectionEnd(PdfWriter writer, Document document, float position) { + events.values().forEach(e -> safeInvoke("onSectionEnd", e, ee -> ee.onSectionEnd(writer, document, position))); + } + + @Override + public void onStartPage(PdfWriter writer, Document document) { + events.values().forEach(e -> safeInvoke("onStartPage", e, ee -> ee.onStartPage(writer, document))); + } + + @Override + public void onEndPage(PdfWriter writer, Document document) { + events.values().forEach(e -> safeInvoke("onEndPage", e, ee -> ee.onEndPage(writer, document))); + } + +} diff --git a/bundles/org.simantics.g2d.ontology/graph.tg b/bundles/org.simantics.g2d.ontology/graph.tg index c215a73cc..362c08c07 100644 Binary files a/bundles/org.simantics.g2d.ontology/graph.tg and b/bundles/org.simantics.g2d.ontology/graph.tg differ diff --git a/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph b/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph index e055f69cc..6f0de29e4 100644 --- a/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph +++ b/bundles/org.simantics.g2d.ontology/graph/G2D.pgraph @@ -26,6 +26,7 @@ G2D.HasPoint2DArray instance()); Variable configurationContext = contexts.getConfigurationContext(); diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java index 3bde5dc42..4a673b97d 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java @@ -33,8 +33,8 @@ public class ServerManagerFactory { public static ServerManager create(String databaseId, String address) throws IOException, DatabaseException { Driver driver = Manager.getDriver(databaseId); if (driver == null) - throw new IllegalArgumentException("Database driver for ID " + databaseId + " Could not be found!"); - System.out.println("ServerManagerFactory.create called with databaseId=" + databaseId + " and driver is " + driver.toString()); + throw new IllegalArgumentException("Database driver with ID " + databaseId + " could not be found!"); + System.out.println("ServerManagerFactory.create called with id " + databaseId + ", driver is " + driver.toString()); DatabaseUserAgent agent = Manager.getUserAgent(databaseId); if (agent != null) driver.setDatabaseUserAgent(address, agent); diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java index 70b9ab039..fd4012355 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java @@ -26,12 +26,12 @@ import org.simantics.db.common.issue.StandardIssue; import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; import org.simantics.db.common.procedure.adapter.TransientCacheListener; import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.common.request.ResourceRead; import org.simantics.db.common.uri.UnescapedChildMapOfResource; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.function.All; import org.simantics.db.layer0.function.StandardChildDomainChildren; -import org.simantics.db.layer0.request.PossibleModel; import org.simantics.db.layer0.request.PropertyInfo; import org.simantics.db.layer0.request.PropertyInfoRequest; import org.simantics.db.layer0.request.VariableRead; @@ -372,7 +372,7 @@ public class Functions { Layer0 L0 = Layer0.getInstance(graph); SimulationResource SIMU = SimulationResource.getInstance(graph); - Resource model = graph.sync(new PossibleModel(resource)); + Resource model = graph.sync(new PossibleIndexRoot(resource)); if(graph.isInstanceOf(model, L0.RVIContext)) { return fromContext(graph, model); } diff --git a/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java index 2d054eaa7..362102172 100644 --- a/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java +++ b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java @@ -134,7 +134,7 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor { /** * Default database ID */ - private static final String DEFAULT_DATABASE_ID = "procore"; + private static final String DEFAULT_DATABASE_ID = "acorn"; /** * The arguments received by the application. diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index 89a5d3dbd..611cfa575 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -39,8 +39,6 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.osgi.service.resolver.BundleDescription; -import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy; -import org.simantics.SimanticsPlatform.RecoveryPolicy; import org.simantics.databoard.Bindings; import org.simantics.databoard.Databoard; import org.simantics.datatypes.literal.Font; @@ -286,7 +284,9 @@ public class SimanticsPlatform implements LifecycleListener { // Check hash of transferable graph to know whether to update or not. if (platformBundle.getHashcode() == existingBundle.getHashcode()) continue; - System.out.println("Ontology hashcodes does not match! platformBundle" + platformBundle.getName() + ".getHashCode()=" + platformBundle.getHashcode() + " existingBundle" + existingBundle.getName() + ".getHashCode()=" + existingBundle.getHashcode()); + System.out.println("Ontology hashcodes do not match: platform bundle=" + + platformBundle.getVersionedId() + ", hash=" + platformBundle.getHashcode() + + "; existing bundle=" + existingBundle.getVersionedId() + ", hash=" + existingBundle.getHashcode()); reinstallTGs.put(platformBundle, existingBundle); } } diff --git a/features/org.simantics.db.client.feature/feature.xml b/features/org.simantics.db.client.feature/feature.xml index d6101139c..14ecb0bf6 100644 --- a/features/org.simantics.db.client.feature/feature.xml +++ b/features/org.simantics.db.client.feature/feature.xml @@ -73,6 +73,13 @@ install-size="0" version="0.0.0"/> + + + + diff --git a/releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition-semantum-intra.target b/releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition-semantum-intra.target deleted file mode 100644 index 8391ce82d..000000000 --- a/releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition-semantum-intra.target +++ /dev/null @@ -1,1122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition-semantum.target b/releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition-semantum.target new file mode 100644 index 000000000..5e8b79969 --- /dev/null +++ b/releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition-semantum.target @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +