X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.wiki.ui%2Fsrc%2Forg%2Fsimantics%2Fwiki%2Fui%2FDefaultWikiTemplateFactory.java;h=aee15046a03ec6de783af28bb9b21c71c871afed;hb=ee806e3464c8255db525712f1d87d46dcb97c1d1;hp=68809e107e280cdb21e143383fcfa94d219d27c9;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/DefaultWikiTemplateFactory.java b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/DefaultWikiTemplateFactory.java index 68809e107..aee15046a 100644 --- a/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/DefaultWikiTemplateFactory.java +++ b/bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/DefaultWikiTemplateFactory.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.wiki.ui; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.document.DocumentResource; -import org.simantics.layer0.Layer0; - -public class DefaultWikiTemplateFactory implements DocumentFactory { - - String template; - - public DefaultWikiTemplateFactory(ReadGraph graph, Resource r) { - template = ""; - - try { - Layer0 l0 = Layer0.getInstance(graph); - DocumentResource DOC = DocumentResource.getInstance(graph); - Resource resource = r; - - while(resource != null) { - if(graph.hasStatement(resource, DOC.HasDocumentTemplate)) { - Resource dt = graph.getSingleObject(resource, DOC.HasDocumentTemplate); - template = (String)graph.getRelatedValue(dt, DOC.HasDocumentation, Bindings.STRING); - break; - } - resource = graph.getPossibleObject(resource, l0.PartOf); - } - } catch (DatabaseException e) { - e.printStackTrace(); - } - } - - @Override - public String createDocument() { - return template; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 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.wiki.ui; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.document.DocumentResource; +import org.simantics.layer0.Layer0; + +public class DefaultWikiTemplateFactory implements DocumentFactory { + + String template; + + public DefaultWikiTemplateFactory(ReadGraph graph, Resource r) { + template = ""; + + try { + Layer0 l0 = Layer0.getInstance(graph); + DocumentResource DOC = DocumentResource.getInstance(graph); + Resource resource = r; + + while(resource != null) { + if(graph.hasStatement(resource, DOC.HasDocumentTemplate)) { + Resource dt = graph.getSingleObject(resource, DOC.HasDocumentTemplate); + template = (String)graph.getRelatedValue(dt, DOC.HasDocumentation, Bindings.STRING); + break; + } + resource = graph.getPossibleObject(resource, l0.PartOf); + } + } catch (DatabaseException e) { + e.printStackTrace(); + } + } + + @Override + public String createDocument() { + return template; + } + +}