X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fproperty%2Fsvg%2FSVGModifier.java;fp=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fproperty%2Fsvg%2FSVGModifier.java;h=e143716ba8bb71e5a3c7856548f2e9caee11a987;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=bbdb0ac5b1476ee213e9b81dbe6895ff1b4a5f50;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGModifier.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGModifier.java index bbdb0ac5b..e143716ba 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGModifier.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGModifier.java @@ -1,43 +1,43 @@ -/******************************************************************************* - * Copyright (c) 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.modeling.ui.property.svg; - -import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl; -import org.simantics.databoard.Bindings; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.stubs.G2DResource; - -/** - * @author Antti Villberg - */ -public class SVGModifier extends TextModifyListenerImpl { - - @Override - public void applyText(WriteGraph graph, SVGInput ui, String text) throws DatabaseException { - if (text == null) - return; - - try { - XMLPrettyPrinter.parseDocument(text); - } catch (Exception e) { - // Never write non-well-formed SVG into the database. - return; - } - - G2DResource G2D = G2DResource.getInstance(graph); - Resource element = ui.getDatum(); - graph.claimLiteral(element, G2D.HasSVGDocument, text, Bindings.STRING); - } - +/******************************************************************************* + * Copyright (c) 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.modeling.ui.property.svg; + +import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl; +import org.simantics.databoard.Bindings; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.diagram.stubs.G2DResource; + +/** + * @author Antti Villberg + */ +public class SVGModifier extends TextModifyListenerImpl { + + @Override + public void applyText(WriteGraph graph, SVGInput ui, String text) throws DatabaseException { + if (text == null) + return; + + try { + XMLPrettyPrinter.parseDocument(text); + } catch (Exception e) { + // Never write non-well-formed SVG into the database. + return; + } + + G2DResource G2D = G2DResource.getInstance(graph); + Resource element = ui.getDatum(); + graph.claimLiteral(element, G2D.HasSVGDocument, text, Bindings.STRING); + } + } \ No newline at end of file