X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fsharedontology%2Fwizard%2FSharedOntologyExporter.java;fp=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fsharedontology%2Fwizard%2FSharedOntologyExporter.java;h=651f55f4ebe4e79f194946fa46b756435bf295ba;hp=e1197d8465f498677cdad5b5a62e6386569a3fa4;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java index e1197d846..651f55f4e 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java @@ -1,75 +1,75 @@ -/******************************************************************************* - * Copyright (c) 2012 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.sharedontology.wizard; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.simantics.Simantics; -import org.simantics.databoard.binding.error.BindingException; -import org.simantics.databoard.serialization.SerializationException; -import org.simantics.db.common.utils.Logger; -import org.simantics.db.exception.DatabaseException; -import org.simantics.modeling.ModelingUtils; -import org.simantics.modeling.ModelingUtils.LibraryInfo; -import org.simantics.utils.ui.dialogs.ShowMessage; - -/** - * @author Antti Villberg - */ -public class SharedOntologyExporter implements IRunnableWithProgress { - - ExportPlan exportModel; - - public SharedOntologyExporter(ExportPlan exportModel) { - this.exportModel = exportModel; - } - - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - SubMonitor progress = SubMonitor.convert(monitor, 50); - try { - exportModel(progress.newChild(50, SubMonitor.SUPPRESS_NONE)); - } catch (IOException e) { - throw new InvocationTargetException(e); - } catch (DatabaseException e) { - throw new InvocationTargetException(e); - } catch (BindingException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - - void exportModel(SubMonitor mon) throws IOException, DatabaseException, SerializationException, BindingException{ - try { - doExport(mon, exportModel.exportLocation, exportModel.model); - - } catch (DatabaseException e) { - e.printStackTrace(); - Logger.defaultLogError(e); - mon.setCanceled(true); - ShowMessage.showError("Export failed.", "Internal application error in export. See log for details."); - } finally { - mon.setWorkRemaining(0); - } - } - - public static void doExport(IProgressMonitor monitor, File location, final LibraryInfo info) throws DatabaseException, IOException { - ModelingUtils.exportSharedOntology(monitor, Simantics.getSession(), location,Constants.SHARED_LIBRARY_FORMAT, Constants.SHARED_LIBRARY_CURRENT_VERSION, info); - } - -} +/******************************************************************************* + * Copyright (c) 2012 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.sharedontology.wizard; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.simantics.Simantics; +import org.simantics.databoard.binding.error.BindingException; +import org.simantics.databoard.serialization.SerializationException; +import org.simantics.db.common.utils.Logger; +import org.simantics.db.exception.DatabaseException; +import org.simantics.modeling.ModelingUtils; +import org.simantics.modeling.ModelingUtils.LibraryInfo; +import org.simantics.utils.ui.dialogs.ShowMessage; + +/** + * @author Antti Villberg + */ +public class SharedOntologyExporter implements IRunnableWithProgress { + + ExportPlan exportModel; + + public SharedOntologyExporter(ExportPlan exportModel) { + this.exportModel = exportModel; + } + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + SubMonitor progress = SubMonitor.convert(monitor, 50); + try { + exportModel(progress.newChild(50, SubMonitor.SUPPRESS_NONE)); + } catch (IOException e) { + throw new InvocationTargetException(e); + } catch (DatabaseException e) { + throw new InvocationTargetException(e); + } catch (BindingException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + + void exportModel(SubMonitor mon) throws IOException, DatabaseException, SerializationException, BindingException{ + try { + doExport(mon, exportModel.exportLocation, exportModel.model); + + } catch (DatabaseException e) { + e.printStackTrace(); + Logger.defaultLogError(e); + mon.setCanceled(true); + ShowMessage.showError("Export failed.", "Internal application error in export. See log for details."); + } finally { + mon.setWorkRemaining(0); + } + } + + public static void doExport(IProgressMonitor monitor, File location, final LibraryInfo info) throws DatabaseException, IOException { + ModelingUtils.exportSharedOntology(monitor, Simantics.getSession(), location,Constants.SHARED_LIBRARY_FORMAT, Constants.SHARED_LIBRARY_CURRENT_VERSION, info); + } + +}