--- /dev/null
+/*******************************************************************************\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.image.ui;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class CreateImages extends WriteRequest {\r
+\r
+ private Resource container;\r
+ private Collection<File> files;\r
+\r
+ public CreateImages(Resource container, Collection<File> files) {\r
+ this.container = container;\r
+ this.files = files;\r
+ }\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ for (File file : files) {\r
+ try {\r
+ ImageSource src = ImportImagesActionFactory.toImageSource(file);\r
+ new CreateImage(container, src).perform(graph);\r
+ } catch (IOException e) {\r
+ ErrorLogger.defaultLogError("Failed to import image " + file.getName() + ", see exception for details.", e);\r
+ }\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file