]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java
Merge "Better emptying of trash bin"
[simantics/platform.git] / bundles / org.simantics.desktop.ui / src / org / simantics / desktop / ui / internal / ExportSharedLibrary.java
index cbc6d06635fea5e425648d1920810a85dfac920e..96f7da83094e142d9ee1998b12943cbf5f2d995c 100644 (file)
@@ -1,65 +1,65 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.desktop.ui.internal;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.UniqueRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.SelectionHints;\r
-import org.simantics.modeling.ModelingUtils;\r
-import org.simantics.scl.runtime.tuple.Tuple0;\r
-import org.simantics.utils.datastructures.hints.IHintContext;\r
-\r
-public class ExportSharedLibrary extends AbstractHandler {\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        \r
-       try {\r
-                       Resource lib = Simantics.sync(new UniqueRead<Resource>() {\r
-\r
-                               @Override\r
-                               public Resource perform(ReadGraph graph) throws DatabaseException {\r
-                                       List<Resource> ontologies =  Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);\r
-                                       if(ontologies.size() == 1) return ontologies.iterator().next();\r
-                                       return null;\r
-                               }\r
-                               \r
-                       });\r
-                       if(lib == null) return null;\r
-                       \r
-            IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
-            context.setHint(SelectionHints.KEY_MAIN, lib);\r
-\r
-                       IStructuredSelection sel = new StructuredSelection(context);\r
-               ModelingUtils.openWizard(Display.getCurrent(), sel, "org.simantics.modeling.ui.sharedOntologyExportWizard");\r
-               } catch (DatabaseException e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
-               }\r
-       \r
-       return null;\r
-        \r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * 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<Resource>() {
+
+                               @Override
+                               public Resource perform(ReadGraph graph) throws DatabaseException {
+                                       List<Resource> 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;
+        
+    }
+
+}