Java Code Examples for org.eclipse.emf.common.util.URI#createPlatformPluginURI()

The following examples show how to use org.eclipse.emf.common.util.URI#createPlatformPluginURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DomainSpecificTaskFinderTest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setup() {
	URI sctWithTasks = URI.createPlatformPluginURI(
			TEST_MODEL_WITH_TASKS, true);
	Resource resource = resourceSet.getResource(sctWithTasks, true);
	foundTasks = taskFinder.findTasks(resource);
}
 
Example 2
Source File: GenerateAll.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings("unchecked")
private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
	Bundle bundle = Platform.getBundle(bundleID);
	if (bundle == null) {
		// no need to go any further
		return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	URL url = bundle.getEntry(relativePath.toString());
	if (url == null && relativePath.segmentCount() > 1) {
		Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
		if (entries != null) {
			String[] segmentsRelativePath = relativePath.segments();
			while (url == null && entries.hasMoreElements()) {
				URL entry = entries.nextElement();
				IPath path = new Path(entry.getPath());
				if (path.segmentCount() > relativePath.segmentCount()) {
					path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
				}
				String[] segmentsPath = path.segments();
				boolean equals = segmentsPath.length == segmentsRelativePath.length;
				for (int i = 0; equals && i < segmentsPath.length; i++) {
					equals = segmentsPath[i].equals(segmentsRelativePath[i]);
				}
				if (equals) {
					url = bundle.getEntry(entry.getPath());
				}
			}
		}
	}
	URI result;
	if (url != null) {
		result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
	} else {
		result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	return result;
}
 
Example 3
Source File: GenerateJava.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings("unchecked")
private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
	Bundle bundle = Platform.getBundle(bundleID);
	if (bundle == null) {
		// no need to go any further
		return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	URL url = bundle.getEntry(relativePath.toString());
	if (url == null && relativePath.segmentCount() > 1) {
		Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
		if (entries != null) {
			String[] segmentsRelativePath = relativePath.segments();
			while (url == null && entries.hasMoreElements()) {
				URL entry = entries.nextElement();
				IPath path = new Path(entry.getPath());
				if (path.segmentCount() > relativePath.segmentCount()) {
					path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
				}
				String[] segmentsPath = path.segments();
				boolean equals = segmentsPath.length == segmentsRelativePath.length;
				for (int i = 0; equals && i < segmentsPath.length; i++) {
					equals = segmentsPath[i].equals(segmentsRelativePath[i]);
				}
				if (equals) {
					url = bundle.getEntry(entry.getPath());
				}
			}
		}
	}
	URI result;
	if (url != null) {
		result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
	} else {
		result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	return result;
}
 
Example 4
Source File: GenerateXml.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings("unchecked")
private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
	Bundle bundle = Platform.getBundle(bundleID);
	if (bundle == null) {
		// no need to go any further
		return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	URL url = bundle.getEntry(relativePath.toString());
	if (url == null && relativePath.segmentCount() > 1) {
		Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
		if (entries != null) {
			String[] segmentsRelativePath = relativePath.segments();
			while (url == null && entries.hasMoreElements()) {
				URL entry = entries.nextElement();
				IPath path = new Path(entry.getPath());
				if (path.segmentCount() > relativePath.segmentCount()) {
					path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
				}
				String[] segmentsPath = path.segments();
				boolean equals = segmentsPath.length == segmentsRelativePath.length;
				for (int i = 0; equals && i < segmentsPath.length; i++) {
					equals = segmentsPath[i].equals(segmentsRelativePath[i]);
				}
				if (equals) {
					url = bundle.getEntry(entry.getPath());
				}
			}
		}
	}
	URI result;
	if (url != null) {
		result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
	} else {
		result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	return result;
}
 
Example 5
Source File: GenerateAll.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings("unchecked")
private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
	Bundle bundle = Platform.getBundle(bundleID);
	if (bundle == null) {
		// no need to go any further
		return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	URL url = bundle.getEntry(relativePath.toString());
	if (url == null && relativePath.segmentCount() > 1) {
		Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
		if (entries != null) {
			String[] segmentsRelativePath = relativePath.segments();
			while (url == null && entries.hasMoreElements()) {
				URL entry = entries.nextElement();
				IPath path = new Path(entry.getPath());
				if (path.segmentCount() > relativePath.segmentCount()) {
					path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
				}
				String[] segmentsPath = path.segments();
				boolean equals = segmentsPath.length == segmentsRelativePath.length;
				for (int i = 0; equals && i < segmentsPath.length; i++) {
					equals = segmentsPath[i].equals(segmentsRelativePath[i]);
				}
				if (equals) {
					url = bundle.getEntry(entry.getPath());
				}
			}
		}
	}
	URI result;
	if (url != null) {
		result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
	} else {
		result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	return result;
}
 
Example 6
Source File: GenerateAll.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings ( "unused" )
private URI getTemplateURI ( final String bundleID, final IPath relativePath ) throws IOException
{
    final Bundle bundle = Platform.getBundle ( bundleID );
    if ( bundle == null )
    {
        // no need to go any further 
        return URI.createPlatformResourceURI ( new Path ( bundleID ).append ( relativePath ).toString (), false );
    }
    URL url = bundle.getEntry ( relativePath.toString () );
    if ( url == null && relativePath.segmentCount () > 1 )
    {
        final Enumeration<URL> entries = bundle.findEntries ( "/", "*.emtl", true );
        if ( entries != null )
        {
            final String[] segmentsRelativePath = relativePath.segments ();
            while ( url == null && entries.hasMoreElements () )
            {
                final URL entry = entries.nextElement ();
                IPath path = new Path ( entry.getPath () );
                if ( path.segmentCount () > relativePath.segmentCount () )
                {
                    path = path.removeFirstSegments ( path.segmentCount () - relativePath.segmentCount () );
                }
                final String[] segmentsPath = path.segments ();
                boolean equals = segmentsPath.length == segmentsRelativePath.length;
                for ( int i = 0; equals && i < segmentsPath.length; i++ )
                {
                    equals = segmentsPath[i].equals ( segmentsRelativePath[i] );
                }
                if ( equals )
                {
                    url = bundle.getEntry ( entry.getPath () );
                }
            }
        }
    }
    URI result;
    if ( url != null )
    {
        result = URI.createPlatformPluginURI ( new Path ( bundleID ).append ( new Path ( url.getPath () ) ).toString (), false );
    }
    else
    {
        result = URI.createPlatformResourceURI ( new Path ( bundleID ).append ( relativePath ).toString (), false );
    }
    return result;
}
 
Example 7
Source File: AbstractTestModelsUtil.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public Statechart loadStatechartFromResource(String fileName) {
	URI uri = URI.createPlatformPluginURI(getModelDirectory() + fileName,
			true);
	return loadStatechart(uri);
}
 
Example 8
Source File: SingleResourceMigrator.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public SingleResourceMigrator() throws MigrationException {
    super(URI.createPlatformPluginURI(getMigrationHistoryPath(), true),
            new BundleClassLoader(MigrationPlugin.getDefault().getBundle()));
}