[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Get the domain model file

I found the solution myself with the help of the following post:


news://news.eclipse.org:119/f4oa0l$fnc$1@xxxxxxxxxxxxxxxxx
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/msg06592.html

My solution is as follows:

public IFile getDomainFileOf(IFile diagramFile) {

    ResourceSet set = new ResourceSetImpl();

    Resource res = set.getResource(
        URI.createPlatformResourceURI(
            diagramFile.getFullPath().toString(),
            true),
        true);

    for (EObject o : res.getContents()) {
        if (o instanceof Diagram) {

            Diagram diagram = (Diagram) o;
            return WorkspaceSynchronizer.getFile(
                diagram.getElement().eResource());
        }
    }
    return null;
}

Any comments?