1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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.modelBrowser.handlers;
15 import java.util.Collection;
17 import org.eclipse.core.commands.AbstractHandler;
18 import org.eclipse.core.commands.ExecutionEvent;
19 import org.eclipse.core.commands.ExecutionException;
20 import org.eclipse.jface.viewers.ISelection;
21 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.ui.handlers.HandlerUtil;
23 import org.simantics.db.Resource;
24 import org.simantics.image.ui.CreateImages;
25 import org.simantics.image.ui.ImportImagesActionFactory;
26 import org.simantics.image.ui.modelBrowser.ImagesNode;
27 import org.simantics.ui.SimanticsUI;
28 import org.simantics.utils.ui.AdaptionUtils;
33 public class ImportImageHandler extends AbstractHandler {
36 public Object execute(ExecutionEvent event) throws ExecutionException {
37 final Shell shell = HandlerUtil.getActiveShell(event);
39 ISelection selection = HandlerUtil.getCurrentSelection(event);
40 ImagesNode images = AdaptionUtils.adaptToSingle(selection, ImagesNode.class);
43 final Resource container = images.data;
45 Collection<File> files = ImportImagesActionFactory.requestImportedImages(shell);
49 SimanticsUI.getSession().asyncRequest( new CreateImages(container, files) );