Project

General

Profile

Download (1.2 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.molecular.handler;
11

    
12

    
13
import java.net.URL;
14

    
15
import org.eclipse.core.runtime.FileLocator;
16
import org.eclipse.core.runtime.Path;
17
import org.eclipse.jface.resource.ImageDescriptor;
18

    
19
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
20

    
21

    
22

    
23
/**
24
 * Implements shared functionality for handler implementations using tool bar icons.
25
 *
26
 * @author Ben Stöver
27
 * @date 15.06.2015
28
 */
29
public class HandlerTools {  //TODO Move this class or method somewhere else?
30
    public static ImageDescriptor createImageDescriptor(String iconName) {
31
        URL url = FileLocator.find(TaxeditorMolecularPlugin.getDefault().getBundle(),
32
                new Path("icons/" + iconName), null);
33
        if (url != null) {
34
            return ImageDescriptor.createFromURL(url);
35
        }
36
        else {
37
            throw new InternalError("Icon \"" + iconName + "\" could not be loaded.");  //TODO Throw other type of exception?
38
        }
39
    }
40
}
(13-13/22)