X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.desktop.ui%2Fsrc%2Forg%2Fsimantics%2Fdesktop%2Fui%2Finternal%2FExportSharedLibrary.java;h=96f7da83094e142d9ee1998b12943cbf5f2d995c;hp=cbc6d06635fea5e425648d1920810a85dfac920e;hb=b844ca924d129072e11f7e4c18918dd388a37e8c;hpb=6a4a43b278d6819c660182eb4954524d1757e077 diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java index cbc6d0663..96f7da830 100644 --- a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java +++ b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java @@ -1,65 +1,65 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.desktop.ui.internal; - -import java.util.List; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.simantics.Simantics; -import org.simantics.browsing.ui.swt.AdaptableHintContext; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.UniqueRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.SelectionHints; -import org.simantics.modeling.ModelingUtils; -import org.simantics.scl.runtime.tuple.Tuple0; -import org.simantics.utils.datastructures.hints.IHintContext; - -public class ExportSharedLibrary extends AbstractHandler { - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - try { - Resource lib = Simantics.sync(new UniqueRead() { - - @Override - public Resource perform(ReadGraph graph) throws DatabaseException { - List ontologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE); - if(ontologies.size() == 1) return ontologies.iterator().next(); - return null; - } - - }); - if(lib == null) return null; - - IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN); - context.setHint(SelectionHints.KEY_MAIN, lib); - - IStructuredSelection sel = new StructuredSelection(context); - ModelingUtils.openWizard(Display.getCurrent(), sel, "org.simantics.modeling.ui.sharedOntologyExportWizard"); - } catch (DatabaseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return null; - - } - -} +/******************************************************************************* + * Copyright (c) 2007, 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.desktop.ui.internal; + +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.simantics.Simantics; +import org.simantics.browsing.ui.common.AdaptableHintContext; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.UniqueRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.SelectionHints; +import org.simantics.modeling.ModelingUtils; +import org.simantics.scl.runtime.tuple.Tuple0; +import org.simantics.utils.datastructures.hints.IHintContext; + +public class ExportSharedLibrary extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + try { + Resource lib = Simantics.sync(new UniqueRead() { + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + List ontologies = Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE); + if(ontologies.size() == 1) return ontologies.iterator().next(); + return null; + } + + }); + if(lib == null) return null; + + IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN); + context.setHint(SelectionHints.KEY_MAIN, lib); + + IStructuredSelection sel = new StructuredSelection(context); + ModelingUtils.openWizard(Display.getCurrent(), sel, "org.simantics.modeling.ui.sharedOntologyExportWizard"); + } catch (DatabaseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + + } + +}