1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.image.ui;
15 import java.io.IOException;
16 import java.util.Collection;
18 import org.simantics.db.Resource;
19 import org.simantics.db.WriteGraph;
20 import org.simantics.db.common.request.WriteRequest;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.utils.ui.ErrorLogger;
25 * @author Tuukka Lehtonen
27 public class CreateImages extends WriteRequest {
29 private Resource container;
30 private Collection<File> files;
32 public CreateImages(Resource container, Collection<File> files) {
33 this.container = container;
38 public void perform(WriteGraph graph) throws DatabaseException {
39 for (File file : files) {
41 ImageSource src = ImportImagesActionFactory.toImageSource(file);
42 new CreateImage(container, src).perform(graph);
43 } catch (IOException e) {
44 ErrorLogger.defaultLogError("Failed to import image " + file.getName() + ", see exception for details.", e);