Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others. 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 /
 
 package org.eclipse.xtext.ui.generator.trace;
 
import  org.eclipse.core.resources.IFile;
import  org.eclipse.core.resources.IMarker;
import  org.eclipse.core.resources.IProject;
import  org.eclipse.core.resources.IResource;
import  org.eclipse.core.resources.IStorage;
import  org.eclipse.core.resources.IWorkspaceRoot;
import  org.eclipse.core.resources.ResourcesPlugin;
import  org.eclipse.core.runtime.CoreException;
import  org.eclipse.ui.IEditorPart;

Author(s):
Moritz Eysholdt - Initial contribution and API
	private final static Logger LOG = Logger.getLogger(DerivedResourceMarkerBasedOpenerContributor.class);
	public boolean collectGeneratedFileOpeners(IEditorPart editorIAcceptor<FileOpeneracceptor) {
		IStorage storage = getStorage(editor);
		if (storage != null) {
			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
			URI uri = URI.createPlatformResourceURI(storage.getFullPath().toString(), true);
			try {
				List<IFile> resources = .findDerivedResources(rooturi.toString());
				for (IFile file : resources)
					acceptor.accept(createOpener(file));
				return true;
catch (CoreException e) {
				.error(e.getMessage(), e);
			}
		}
		return false;
	}
	public boolean collectSourceFileOpeners(IEditorPart editorIAcceptor<FileOpeneracceptor) {
		IStorage storage = getStorage(editor);
		if (storage instanceof IResource) {
			IResource resource = (IResource) storage;
			try {
				Set<URIuris = Sets.newHashSet();
				IMarker[] markers = .findDerivedResourceMarkers(resource);
				for (IMarker marker : markers) {
					if (source != null)
						uris.add(URI.createURI(source));
				}
				for (URI uri : uris)
					for (Pair<IStorage, IProject> destination : .getStorages(uri))
						acceptor.accept(createOpener(destination.getFirst()));
				return true;
catch (CoreException e) {
				.error(e.getMessage(), e);
			}
		}
		return false;
	}
New to GrepCode? Check out our FAQ X