use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject 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.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class ProjectDescriptionLoadListener method onDescriptionLoaded.
void onDescriptionLoaded(URI location) {
if (location.isPlatformResource() && location.segmentCount() == 2) {
IN4JSEclipseProject n4project = eclipseCore.create(location);
IProject eclipseProject = n4project.getProject();
updateProjectReferencesIfNecessary(eclipseProject);
}
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class N4JSEclipseModel method findN4JSSourceContainer.
@Override
public Optional<? extends IN4JSSourceContainer> findN4JSSourceContainer(URI location) {
Optional<? extends IN4JSSourceContainer> n4jsContainer = Optional.absent();
if (!location.isArchive()) {
if (N4Scheme.isN4Scheme(location)) {
return n4jsContainer;
}
if (!location.isPlatformResource()) {
// just do not throw exception then, but continue with null:
if ("revision".equals(location.scheme())) {
if (LOGGER.isDebugEnabled()) {
final String message = "Got revision-scheme request, but refuse to find source-container for that:" + location;
LOGGER.debug(message);
}
return n4jsContainer;
}
if (location.isFile()) {
final IN4JSEclipseProject eclipseProject = findProjectWith(location);
if (null != eclipseProject && eclipseProject.exists()) {
if (eclipseProject.getProject() instanceof ExternalProject) {
final IResource resource = externalLibraryWorkspace.getResource(location);
if (null != resource) {
n4jsContainer = getN4JSSourceContainer(resource);
}
}
}
}
return n4jsContainer;
}
final IN4JSEclipseProject project = findProjectWith(location);
if (null != project && project.exists()) {
final Path path = new Path(location.toPlatformString(true));
final IResource resource;
if (1 == path.segmentCount()) {
resource = workspace.getProject(path.segment(0));
} else {
resource = workspace.getFile(path);
}
n4jsContainer = getN4JSSourceContainer(resource);
}
} else {
String archiveFilePath = location.authority();
URI archiveURI = URI.createURI(archiveFilePath.substring(0, archiveFilePath.length() - 1));
N4JSEclipseProject containingProject = findProjectWith(archiveURI);
N4JSEclipseArchive archive = getN4JSArchive(containingProject, workspace.getFile(new Path(archiveURI.toPlatformString(true))));
n4jsContainer = findN4JSSourceContainerInArchive(location, archive);
}
return n4jsContainer;
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class NpmExportWizard method init.
@Override
public void init(IWorkbench targetWorkbench, IStructuredSelection currentSelection) {
// this.selection = currentSelection;
List<?> selectedResources = IDE.computeSelectedResources(currentSelection);
List<IProject> workspaceProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
// Find all selected projects
Set<IProject> projects = selectedResources.stream().filter(m -> m instanceof IResource).map(m -> ((IResource) m).getProject()).filter(// only open projects
p -> p.isOpen()).collect(Collectors.toSet());
// make the behavior predictable by ordering:
TreeSet<IProject> sortedProjects = Sets.<IProject>newTreeSet((a, b) -> a.getName().compareToIgnoreCase(b.getName()));
sortedProjects.addAll(projects);
// 0) turn into IN4JSProject and give and process further.
// a) find out which projects fulfill the npm-"exportable"-contract
// b) give back a list to the user what to export,
// c) disable things not fullfilling the contract.
// d) take choosing from the list and pass to exporter in non-ui package.
// 0)
List<IN4JSEclipseProject> rawN4jsProjects = Lists.newArrayList();
iP2in4jsP = HashBiMap.create();
for (IProject iProject : workspaceProjects) {
IN4JSEclipseProject mappedIn4jsProject = map2In4js(iProject);
if (mappedIn4jsProject != null) {
rawN4jsProjects.add(mappedIn4jsProject);
iP2in4jsP.put(iProject, mappedIn4jsProject);
}
}
// filter out Non-N4JS-projects from initial selection.
sortedProjects.retainAll(iP2in4jsP.keySet());
// filter out all non-N4JS-projects from the workspace projects.
ArrayList<IProject> filteredWorkspaceProjects = new ArrayList<>(workspaceProjects);
filteredWorkspaceProjects.retainAll(iP2in4jsP.keySet());
setWindowTitle("N4JS to npm Export");
setNeedsProgressMonitor(true);
Map<IProject, Boolean> selectedProjects = new HashMap<>();
// Add all workspace projects to list, default selection value is false
filteredWorkspaceProjects.forEach(project -> selectedProjects.put(project, false));
// Override selection value for all initially selected projects
sortedProjects.forEach(project -> selectedProjects.put(project, true));
// exportPage = new ExportSelectionPage("Export Page", rawN4jsProjects, labelProvider);
exportPage = new ExportSelectionPage("Export Page", selectedProjects);
if (runTools())
toolRunnerPage = new NpmToolRunnerPage("npm Execution Page");
comparePage = new PackageJsonComparePage("Compare package.json Page");
pageListener = new IPageChangedListener() {
@Override
public void pageChanged(PageChangedEvent event) {
if (event.getSelectedPage() == comparePage) {
udpatePackagJasonComparison();
}
}
};
}
use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.
the class NpmExportWizard method map2In4js.
/**
* @param iProject
* project from selection
* @return
*/
private IN4JSEclipseProject map2In4js(IProject iProject) {
URI projectURI = URI.createPlatformResourceURI(iProject.getName(), true);
IN4JSEclipseProject project = n4JSCore.findProject(projectURI).orNull();
// Additionally check for existence to only obtain visible N4JS workspace projects.
if (project.exists()) {
return project;
} else {
return null;
}
}
Aggregations