use of org.eclipse.n4js.ts.ui.navigation.URIBasedStorage in project n4js by eclipse.
the class NfarStorageMapper method getStorages.
@Override
public Iterable<Pair<IStorage, IProject>> getStorages(URI uri) {
if (uri.isArchive()) {
URIBasedStorage storage = new URIBasedStorage(uri);
String authority = uri.authority();
URI archiveFileURI = URI.createURI(authority.substring(0, authority.length() - 1));
Optional<? extends IN4JSEclipseProject> optionalProject = eclipseCore.findProject(archiveFileURI);
if (optionalProject.isPresent()) {
return Collections.singletonList(Tuples.<IStorage, IProject>create(storage, optionalProject.get().getProject()));
} else {
return Collections.singletonList(Tuples.create(storage, null));
}
} else {
return Collections.emptyList();
}
}
use of org.eclipse.n4js.ts.ui.navigation.URIBasedStorage in project n4js by eclipse.
the class N4JSToBeBuiltComputer method updateStorage.
@Override
public boolean updateStorage(ToBeBuilt toBeBuilt, IStorage storage, IProgressMonitor monitor) {
if (storage instanceof IFile) {
IFile file = (IFile) storage;
String extension = file.getFileExtension();
// changed archive - schedule contents
if (IN4JSArchive.NFAR_FILE_EXTENSION.equals(extension)) {
IProject project = file.getProject();
String key = project.getName() + "|" + storage.getFullPath().toPortableString();
Set<URI> cachedURIs = knownEntries.remove(key);
if (cachedURIs != null) {
toBeBuilt.getToBeDeleted().addAll(cachedURIs);
}
cachedURIs = Sets.newHashSet();
storageMapper.collectNfarURIs((IFile) storage, cachedURIs);
knownEntries.put(key, cachedURIs);
toBeBuilt.getToBeUpdated().addAll(cachedURIs);
return true;
} else if (IN4JSProject.N4MF_MANIFEST.equals(file.getName())) {
// changed manifest - schedule all resources from source folders
final IN4JSEclipseProject project = eclipseCore.create(file.getProject()).orNull();
if (null != project && project.exists()) {
List<? extends IN4JSEclipseSourceContainer> sourceContainers = project.getSourceContainers();
Set<URI> toBeUpdated = toBeBuilt.getToBeUpdated();
for (IN4JSEclipseSourceContainer sourceContainer : sourceContainers) {
for (URI uri : sourceContainer) {
if (uriValidator.canBuild(uri, new URIBasedStorage(uri))) {
toBeUpdated.add(uri);
}
}
}
}
IProject resourceProject = file.getProject();
String projectName = resourceProject.getName();
Set<URI> toBeDeleted = toBeBuilt.getToBeDeleted();
for (final IResourceDescription description : builderState.getAllResourceDescriptions()) {
URI uri = description.getURI();
if (uri.isPlatformResource()) {
if (projectName.equals(uri.segment(1))) {
toBeDeleted.add(uri);
}
}
}
// still return false because we want to do the normal processing for the manifest file, too
return false;
}
}
return false;
}
use of org.eclipse.n4js.ts.ui.navigation.URIBasedStorage in project n4js by eclipse.
the class N4JSResourceLinkHelper method activateEditor.
@Override
public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) {
if (null != selection && !selection.isEmpty()) {
final Object firstElement = selection.getFirstElement();
if (firstElement instanceof ResourceNode) {
final File fileResource = ((ResourceNode) firstElement).getResource();
if (fileResource.exists() && fileResource.isFile()) {
final URI uri = URI.createFileURI(fileResource.getAbsolutePath());
final IResource resource = externalLibraryWorkspace.getResource(uri);
if (resource instanceof IFile) {
final IEditorInput editorInput = EditorUtils.createEditorInput(new URIBasedStorage(uri));
final IEditorPart editor = page.findEditor(editorInput);
if (null != editor) {
page.bringToTop(editor);
return;
}
}
}
}
}
super.activateEditor(page, selection);
}
Aggregations