Skip to main content
summaryrefslogtreecommitdiffstats
blob: ba5484a6b1f3d11df87fcbc36376f49a4aad4d27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**********************************************************************
 * This file is part of "Object Teams Development Tooling"-Software
 * 
 * Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
 * for its Fraunhofer Institute and Computer Architecture and Software
 * Technology (FIRST), Berlin, Germany and Technical University Berlin,
 * Germany.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * $Id$
 * 
 * Please visit http://www.eclipse.org/objectteams for updates and contact.
 * 
 * Contributors:
 * 	  Fraunhofer FIRST - Initial API and implementation
 * 	  Technical University Berlin - Initial API and implementation
 **********************************************************************/
package org.eclipse.objectteams.otdt.ui.tests.refactoring;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;

/**
 * The main plugin class to be used in the desktop.
 */
public class OTRefactoringTestPlugin extends Plugin
{
    //The shared instance.
    private static OTRefactoringTestPlugin plugin;

    public OTRefactoringTestPlugin()
    {
        super();
        plugin = this;
    }

    /**
     * Returns the shared instance.
     */
    public static OTRefactoringTestPlugin getDefault()
    {
        return plugin;
    }

    public static IWorkspace getWorkspace()
    {
        return ResourcesPlugin.getWorkspace();
    }

    public File getFileInPlugin(IPath path)
    {
        try
        {
            URL installURL = new URL(getDefault().getBundle().getEntry("/"), path.toString());
            URL localURL = Platform.asLocalURL(installURL);
            return new File(localURL.getFile());
        }
        catch (IOException ex)
        {
            return null;
        }
    }

    public InputStream getTestResourceStream(String fileName)
            throws IOException
    {
        IPath path = new Path("testdata").append(fileName);
        URL url = new URL(getDefault().getBundle().getEntry("/"), path.toString());
        return url.openStream();
    }
}

Back to the top