]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.image.ui/src/org/simantics/image/ui/CreateImages.java
2fe579533849adef66152b0ba9dfb87d096212c3
[simantics/platform.git] / bundles / org.simantics.image.ui / src / org / simantics / image / ui / CreateImages.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.image.ui;
13
14 import java.io.File;
15 import java.io.IOException;
16 import java.util.Collection;
17
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;
23
24 /**
25  * @author Tuukka Lehtonen
26  */
27 public class CreateImages extends WriteRequest {
28
29     private Resource         container;
30     private Collection<File> files;
31
32     public CreateImages(Resource container, Collection<File> files) {
33         this.container = container;
34         this.files = files;
35     }
36
37     @Override
38     public void perform(WriteGraph graph) throws DatabaseException {
39         for (File file : files) {
40             try {
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);
45             }
46         }
47     }
48
49 }