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.IStorage;
import  org.eclipse.ui.IEditorPart;

Author(s):
Moritz Eysholdt - Initial contribution and API
	protected StorageBasedTextEditorOpener createStorageBasedTextEditorOpener(IStorage storageITextRegion textRegion) {
		return new StorageBasedTextEditorOpener(storagetextRegion);
	}
	public boolean collectGeneratedFileOpeners(IEditorPart editorIAcceptor<FileOpeneracceptor) {
		IStorage editorStorage = getStorage(editor);
		if (editorStorage != null) {
			if (trace != null && ((ITrace.Internaltrace).getRootTraceRegion() != null) {
				collectOpeners(tracegetSelectedRegion(editor), acceptor);
				return true;
			}
		}
		return false;
	}
	private void collectOpeners(ITrace traceITextRegion regionIAcceptor<FileOpeneracceptor) {
		Iterable<ILocationInResourcelocations = null;
		if (region != null)
			locations = trace.getAllAssociatedLocations(region);
		if (locations == null || Iterables.isEmpty(locations))
			locations = trace.getAllAssociatedLocations();
		Map<IStorage, ITextRegionresult = Maps.newHashMap();
		for (ILocationInResource location : locations) {
			IStorage storage = location.getStorage();
			if (storage != null) {
				ITextRegion old = result.put(storagelocation.getTextRegion());
				if (old != null) {
					ITextRegion merged = old.merge(location.getTextRegion());
					result.put(storagemerged);
				}
			}
		}
		for (Map.Entry<IStorage, ITextRegione : result.entrySet()) {
			IStorage storage = e.getKey();
			ITextRegion textRegion = e.getValue();
			acceptor.accept(createStorageBasedTextEditorOpener(storagetextRegion));
		}
	}
	public boolean collectSourceFileOpeners(IEditorPart editorIAcceptor<FileOpeneracceptor) {
		IStorage editorStorage = getStorage(editor);
		if (editorStorage != null) {
			if (((ITrace.Internaltrace).getRootTraceRegion() != null) {
				collectOpeners(tracegetSelectedRegion(editor), acceptor);
				return true;
			}
		}
		return false;
	}
New to GrepCode? Check out our FAQ X