org.eclipse.core.filesystem.IFileStore Java Examples

The following examples show how to use org.eclipse.core.filesystem.IFileStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NavigatorLinkHelper.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IStructuredSelection findSelection(IEditorInput input) {
  IFile file = ResourceUtil.getFile(input);

  if (file != null) {
    return new StructuredSelection(file);
  }

  IFileStore fileStore = (IFileStore) input.getAdapter(IFileStore.class);

  if (fileStore == null && input instanceof FileStoreEditorInput) {
    URI uri = ((FileStoreEditorInput)input).getURI();
    
    try {
      fileStore = EFS.getStore(uri);
    } catch (CoreException e) {

    }
  }
  
  if (fileStore != null) {
    return new StructuredSelection(fileStore);
  }

  return StructuredSelection.EMPTY;
}
 
Example #2
Source File: IndexFilesOfProjectJob.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected Set<IFileStore> toFileStores(IProgressMonitor monitor)
{
	SubMonitor sub = SubMonitor.convert(monitor, files.size());
	Set<IFileStore> fileStores = new HashSet<IFileStore>(files.size());
	for (IFile file : files)
	{
		try
		{
			IFileStore store = EFS.getStore(file.getLocationURI());
			if (store == null)
			{
				continue;
			}
			fileStores.add(store);
		}
		catch (CoreException e)
		{
			IdeLog.logError(IndexPlugin.getDefault(), e);
		}
		finally
		{
			sub.worked(1);
		}
	}
	return fileStores;
}
 
Example #3
Source File: IndexRequestJob.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * getContributedFiles
 * 
 * @param container
 * @return
 */
protected Set<IFileStore> getContributedFiles(URI container)
{
	Set<IFileStore> result = new HashSet<IFileStore>();
	IndexManager manager = getIndexManager();

	if (manager != null)
	{
		for (IIndexFileContributor contributor : manager.getFileContributors())
		{
			Set<IFileStore> files = contributor.getFiles(container);

			if (!CollectionsUtil.isEmpty(files))
			{
				result.addAll(files);
			}
		}
	}

	return result;
}
 
Example #4
Source File: PackagerTest.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testCFIgnoreNegation() throws Exception {
	ZipOutputStream mockZos = mock(ZipOutputStream.class);

	String LOCATION = "testData/packagerTest/02"; //$NON-NLS-1$
	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(LOCATION);
	IFileStore source = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath()));

	PackageUtils.writeZip(source, mockZos);

	/* what is... */
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry(".cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/.cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/test.in")))); //$NON-NLS-1$

	/* ... and what should never be */
	verify(mockZos, never()).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/test2.in")))); //$NON-NLS-1$
}
 
Example #5
Source File: LoadDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void okPressed() {
    fIsForce = fForceButton.getSelection();
    if (fFileWidget != null) {
        fRemoteFiles = fFileWidget.getResources();
        if (!fRemoteFiles.isEmpty()) {
            super.okPressed();
        }
        return;
    }

    Object[] files = fFolderViewer.getCheckedElements();
    List<IFileStore> stores = new ArrayList<>();
    for (Object file : files) {
        if (file instanceof File) {
            stores.add(EFS.getLocalFileSystem().fromLocalFile((File) file));
        }
    }
    if (!stores.isEmpty()) {
        fLocalFiles = stores;
        super.okPressed();
    }
}
 
Example #6
Source File: ManifestUtilsTest.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testFlatComplexInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/06"; //$NON-NLS-1$
	String manifestName = "final-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(2, applications.getChildren().size());

	for (ManifestParseTree application : applications.getChildren()) {
		assertTrue(application.has("domain")); //$NON-NLS-1$
		assertTrue(application.has("instances")); //$NON-NLS-1$
		assertTrue(application.has("memory")); //$NON-NLS-1$

		if ("A".equals(application.get("name").getValue())) //$NON-NLS-1$ //$NON-NLS-2$
			assertTrue("2".equals(application.get("instances").getValue())); //$NON-NLS-1$ //$NON-NLS-2$
	}
}
 
Example #7
Source File: BuildSettingWizardPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
private static File createBackup(IFileStore source, String name) throws CoreException {
	try {
		final File bak = File.createTempFile("eclipse-" + name, ".bak"); //$NON-NLS-1$//$NON-NLS-2$
		copyFile(source, bak);
		return bak;
	} catch (IOException e) {
		final IStatus status = new Status(
				IStatus.ERROR,
				JavaUI.ID_PLUGIN,
				IStatus.ERROR,
				MessageFormat.format(
				NewWizardMessages.NewJavaProjectWizardPageTwo_problem_backup,
				name),
				e);
		throw new CoreException(status);
	}
}
 
Example #8
Source File: FileHandlerV1.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
private void handleMultiPartGet(HttpServletRequest request, HttpServletResponse response, IFileStore file) throws IOException, CoreException,
		NoSuchAlgorithmException, JSONException {
	String boundary = createBoundaryString();
	response.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
	response.setHeader(ProtocolConstants.HEADER_ACCEPT_PATCH, ProtocolConstants.CONTENT_TYPE_JSON_PATCH);
	response.setHeader(ProtocolConstants.HEADER_CONTENT_TYPE, "multipart/related; boundary=\"" + boundary + '"'); //$NON-NLS-1$
	OutputStream outputStream = response.getOutputStream();
	Writer out = new OutputStreamWriter(outputStream, "UTF-8");
	out.write("--" + boundary + EOL); //$NON-NLS-1$
	out.write("Content-Type: application/json" + EOL + EOL); //$NON-NLS-1$
	appendGetMetadata(request, response, out, file);
	out.write(EOL + "--" + boundary + EOL); //$NON-NLS-1$
	// headers for file contents go here
	out.write(EOL);
	out.flush();
	IOUtilities.pipe(file.openInputStream(EFS.NONE, null), outputStream, true, false);
	out.write(EOL + "--" + boundary + EOL); //$NON-NLS-1$
	out.flush();
}
 
Example #9
Source File: OpenLogCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	IFileStore fileStore = EFS.getLocalFileSystem().getStore(Platform.getLogFileLocation());
	try {
		IDE.openEditorOnFileStore(page, fileStore);
	} catch (PartInitException e) {
		BonitaStudioLog.error(e);
		try {
			IDE.openInternalEditorOnFileStore(page, fileStore);
		} catch (PartInitException e1) {
			BonitaStudioLog.error(e1);
			BonitaStudioLog.log("Can't open .log file in editor. You should associate .log to a program at OS level.");
		}
	}		
	return null;
}
 
Example #10
Source File: SftpFileStore.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
	SynchronizedChannel channel = getChannel();
	try {
		try {
			channel.mkdir(getPathString(channel));
		} catch (SftpException sftpException) {
			//jsch mkdir fails if dir already exists, but EFS API says we should not fail
			SftpATTRS stat = channel.stat(getPathString(channel));
			if (stat.isDir())
				return this;
			//rethrow and fail
			throw sftpException;
		}
	} catch (Exception e) {
		ChannelCache.flush(host);
		throw wrap(e);
	}
	return this;
}
 
Example #11
Source File: CoreFilesTest.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testListenerWriteFile() throws CoreException, IOException, SAXException, JSONException {
	String directoryPath = "sample/directory/path" + System.currentTimeMillis();
	IFileStore dir = createDirectory(directoryPath);
	String fileName = "testfile.txt";

	WebRequest request = getPostFilesRequest(directoryPath, getNewFileJSON(fileName).toString(), fileName);
	WebResponse response = webConversation.getResponse(request);
	assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());

	modListener = new TestFilesystemModificationListener();

	//put to file location should succeed
	String location = response.getHeaderField("Location");
	String fileContent = "New contents";
	request = getPutFileRequest(location, fileContent);
	response = webConversation.getResponse(request);
	assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

	modListener.assertListenerNotified(dir.getChild(fileName), ChangeType.WRITE);
}
 
Example #12
Source File: NodeJSDeploymentPlanner.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Looks for a Procfile and parses the web command.
 * @return <code>null</code> iff there is no Procfile present or it does not contain a web command.
 */
protected String getProcfileCommand(IFileStore contentLocation) {
	IFileStore procfileStore = contentLocation.getChild(ManifestConstants.PROCFILE);
	if (!procfileStore.fetchInfo().exists())
		return null;

	InputStream is = null;
	try {

		is = procfileStore.openInputStream(EFS.NONE, null);
		Procfile procfile = Procfile.load(is);
		return procfile.get(ManifestConstants.WEB);

	} catch (Exception ex) {
		/* can't parse the file, fail */
		return null;

	} finally {
		IOUtilities.safeClose(is);
	}
}
 
Example #13
Source File: GoNavigatorActionProvider.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean isEnabled() {
	ISelection selection = selectionProvider.getSelection();
	if(selection.isEmpty() || !(selection instanceof StructuredSelection)) {
		return false;
	}
	StructuredSelection ss = (StructuredSelection) selection;
	if(ss.size() == 1 && ss.getFirstElement() instanceof IFileStore) {
		IFileStore fileStore = (IFileStore) ss.getFirstElement();
		if(!fileStore.fetchInfo().isDirectory()) {
			this.fileStore = fileStore;
			return true;
		}
		return false;
	}
	return false;
}
 
Example #14
Source File: URIResolver.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected IFileStore getFileStore(URI uri) throws CoreException
{
	IFileSystem fileSystem = EFS.getFileSystem(uri.getScheme());
	if (fileSystem == null)
	{
		return EFS.getNullFileSystem().getStore(uri);
	}
	return fileSystem.getStore(uri);
}
 
Example #15
Source File: FileHandlerV1.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private void handlePutMetadata(BufferedReader reader, String boundary, IFileStore file) throws IOException, CoreException, JSONException {
	StringBuffer buf = new StringBuffer();
	String line;
	while ((line = reader.readLine()) != null && !line.equals(boundary))
		buf.append(line);
	// merge with existing metadata
	FileInfo info = (FileInfo) file.fetchInfo(EFS.NONE, null);
	ServletFileStoreHandler.copyJSONToFileInfo(new JSONObject(buf.toString()), info);
	file.putInfo(info, EFS.SET_ATTRIBUTES, null);
}
 
Example #16
Source File: MarkerCollectorParserEventListener.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void addMarkerInfo( boolean isError, IFileStore file, CharSequence chars
		                  , TextPosition position, int length, String message )
{
	FileMarkerInfo fileMarkerInfo = getFileMarkerInfo(file);
	if (fileMarkerInfo != null) {
		MarkerInfo markerInfo = createMarkerInfo(fileMarkerInfo.getIFile(), isError, chars, position, length, message);
		fileMarkerInfo.addParserMarker(markerInfo);
	}
}
 
Example #17
Source File: NewFileServlet.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	traceRequest(req);
	String pathInfo = req.getPathInfo();
	IPath path = pathInfo == null ? Path.ROOT : new Path(pathInfo);

	// prevent path canonicalization hacks
	if (pathInfo != null && !pathInfo.equals(path.toString())) {
		handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", pathInfo), null));
		return;
	}
	//don't allow anyone to mess with metadata
	if (path.segmentCount() > 0 && ".metadata".equals(path.segment(0))) { //$NON-NLS-1$
		handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", pathInfo), null));
		return;
	}
	IFileStore file = getFileStore(req, path);
	IFileStore testLink = file;
	while (testLink != null) {
		IFileInfo info = testLink.fetchInfo();
		if (info.getAttribute(EFS.ATTRIBUTE_SYMLINK)) {
			if (file == testLink) {
				handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, NLS.bind("Forbidden: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null));
			} else {
				handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("File not found: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null));
			}
			return;
		}
		testLink = testLink.getParent();
	}

	if (file == null) {
		handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("File not found: {0}", EncodingUtils.encodeForHTML(pathInfo.toString())), null));
		return;
	}
	if (fileSerializer.handleRequest(req, resp, file))
		return;
	// finally invoke super to return an error for requests we don't know how to handle
	super.doGet(req, resp);
}
 
Example #18
Source File: FileStoreNotificationWrapper.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
	IFileStore[] toWrap = wrapped.childStores(options, monitor);

	for (int i = 0; i < toWrap.length; i++) {
		toWrap[i] = wrap(source, toWrap[i]);
	}

	return toWrap;
}
 
Example #19
Source File: ClientImport.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean hasExcludedParent(IFileStore destination, IFileStore destinationRoot, List<String> excludedFiles) {
	if (destination.equals(destinationRoot)) {
		return false;
	}
	if (excludedFiles.contains(destination.getName())) {
		return true;
	}
	return hasExcludedParent(destination.getParent(), destinationRoot, excludedFiles);
}
 
Example #20
Source File: DocumentAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructs a new document adapter.
 * 
 * @param owner the owner of this buffer
 * @param fileStore the file store of the file that backs the buffer
 * @param path the path of the file that backs the buffer
 * @since 3.6
 */
public DocumentAdapter(IOpenable owner, IFileStore fileStore, IPath path) {
	Assert.isLegal(fileStore != null);
	Assert.isLegal(path != null);
	fOwner= owner;
	fFileStore= fileStore;
	fPath= path;
	fLocationKind= LocationKind.NORMALIZE;

	initialize();
}
 
Example #21
Source File: XdsModel.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public void putNonWorkspaceXdsElement(IFileStore sourceFile,
   		IXdsElement xdsElement) {
   	Lock writeLock = instanceLock.writeLock();
   	try{
   		writeLock.lock();
   		location2XdsElement.put(new PathWithLocationType(sourceFile) , xdsElement);
   	}
   	finally {
   		writeLock.unlock();
   	}
}
 
Example #22
Source File: EditorManager.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void partOpened(IWorkbenchPart part) {
	IEditorPart editorPart = getEditorPart(part);
	if (editorPart != null) {
		IEditorInput editorInput = editorPart.getEditorInput();
		IResource resource = (IResource)editorInput.getAdapter(IResource.class);
		if (resource == null) {
			IFileStore fileStore = CoreEditorUtils.editorInputToFileStore(editorInput);
			if (fileStore != null) {
				IEditableXdsModel editableModel = XdsModelManager.getEditableModel();
				editableModel.createNonWorkspaceXdsElement(fileStore);
			}
		}
	}
}
 
Example #23
Source File: FileStoreNotificationWrapper.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Wrap the given store. When the wrapper is used to perform writes, change events
 * will be generated. 
 */
public static FileStoreNotificationWrapper wrap(Object source, IFileStore store) {
	if (store == null) {
		return null;
	}

	return new FileStoreNotificationWrapper(source, store);
}
 
Example #24
Source File: ConsoleParseEventReporter.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void endFileParsing(IFileStore file) {
    if (file != null) {
    	printAbsolutePath(System.out, file);
    }
    System.out.println( "-- Total errors: " + errorCount + " warnings: " + warningCount); 
}
 
Example #25
Source File: IRepositoryTests.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public void testCrossReferenceAcrossRepositories() throws CoreException, IOException {
    IFileStore repoDir1 = getBaseDir().getChild("repo1");
    IRepository repo1 = MDDCore.createRepository(MDDUtil.fromJavaToEMF(repoDir1.toURI()));
    repo1.createPackage("package1");
    repo1.save(null);
    repo1.dispose();

    repo1 = MDDCore.createRepository(repo1.getBaseURI());

    Properties repo2Properties = new Properties();
    repo2Properties.setProperty(IRepository.IMPORTED_PROJECTS, repo1.getBaseURI().toString());
    IFileStore repoDir2 = getBaseDir().getChild("repo2");
    saveSettings(repoDir2, repo2Properties);
    IRepository repo2 = MDDCore.createRepository(MDDUtil.fromJavaToEMF(repoDir2.toURI()));
    repo2.loadPackage(EcoreUtil.getURI(repo1.loadPackage("package1")));
    repo1.dispose();
    Package package2 = repo2.createPackage("package2");
    Package loadedPackage1 = repo2.findPackage("package1", null);
    assertNotNull(loadedPackage1);
    package2.createPackageImport(loadedPackage1);
    repo2.save(null);

    File baseDir = new File(repo2.getBaseURI().toFileString());
    assertEquals(Arrays.asList("package2.uml"), new ArrayList<String>(listUMLFileNames(repoDir2)));
    File package2File = new File(baseDir, "package2.uml");
    String packageContents = FileUtils.readFileToString(package2File);
    assertEquals(-1, packageContents.indexOf("file:"));
    assertTrue(packageContents.indexOf("\"../repo1/package1.uml") > 0);
}
 
Example #26
Source File: FileStoreNotificationWrapper.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public void move(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
	destination = unwrap(destination);

	wrapped.move(destination, options, monitor);

	// Tested by CoreFilesTest.testListenerMoveFileNoOverwrite()
	notifyOfWrite(new ChangeEvent(source, ChangeType.MOVE, destination, wrapped));
}
 
Example #27
Source File: SimpleMetaStore.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IFileStore getUserHome(String userId) {
	IFileStore root = OrionConfiguration.getRootLocation();
	if (userId != null) {
		// the format of the user home is /serverworkspace/an/anthony
		String userPrefix = userId.substring(0, Math.min(2, userId.length()));
		return root.getChild(userPrefix).getChild(userId);
	}
	// for backwards compatibility, if userId is null, the old API used to return the root location;
	return root;
}
 
Example #28
Source File: ManifestMetaModel.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public BluemixManifestEditorInput(IFileStore fileStore, IDominoDesignerProject project) {
    super(fileStore);
    _designerProject = project;
    
    // Get the file link for the manifest - This allows us to sync with
    // the Navigator and close the manifest when the project is closing
    _fileLink = project.getProject().getFile(MANIFEST_PATH);
    try {                
        // Is the correct file link in place ?
        if (_fileLink.getLocationURI().equals(getURI())) {
            // Yes, refresh the resource - this is needed or we run into
            // file sync problems, not sure why !!!
            _fileLink.refreshLocal(IResource.DEPTH_ZERO, null);
        } else {
            // No, create the link - this modifies the .project file
            // The link has to be created in the project root, links in sub-dirs
            // cause exceptions when opening an NSF
            _fileLink.createLink(getURI(), IResource.REPLACE, null);
        }

    } catch (CoreException e) {
        if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) {
            BluemixLogger.BLUEMIX_LOGGER.errorp(this, "BluemixManifestEditorInput", e, "Failed to create or refresh the manifest file link"); // $NON-NLS-1$ $NLE-ManifestMetaModel.Failedtocreateorrefreshthemanifes-2$
        }
    }
    
}
 
Example #29
Source File: CompilationUnitDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a fake compilation unit.
 *
 * @param editorInput the URI editor input
 * @return the fake compilation unit
 * @since 3.3
 */
private ICompilationUnit createFakeCompiltationUnit(IURIEditorInput editorInput) {
	try {
		final URI uri= editorInput.getURI();
		final IFileStore fileStore= EFS.getStore(uri);
		final IPath path= URIUtil.toPath(uri);
		String fileStoreName= fileStore.getName();
		if (fileStoreName == null || path == null)
			return null;

		WorkingCopyOwner woc= new WorkingCopyOwner() {
			/*
			 * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit)
			 * @since 3.2
			 */
			@Override
			public IBuffer createBuffer(ICompilationUnit workingCopy) {
				return new DocumentAdapter(workingCopy, fileStore, path);
			}
		};

		IClasspathEntry[] cpEntries= null;
		IJavaProject jp= findJavaProject(path);
		if (jp != null)
			cpEntries= jp.getResolvedClasspath(true);

		if (cpEntries == null || cpEntries.length == 0)
			cpEntries= new IClasspathEntry[] { JavaRuntime.getDefaultJREContainerEntry() };

		final ICompilationUnit cu= woc.newWorkingCopy(fileStoreName, cpEntries, getProgressMonitor());

		if (!isModifiable(editorInput))
			JavaModelUtil.reconcile(cu);

		return cu;
	} catch (CoreException ex) {
		return null;
	}
}
 
Example #30
Source File: EFSUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * getFiles
 * 
 * @param file
 * @param recurse
 * @param list
 * @param includeCloakedFiles
 * @param monitor
 *            the progress monitor to use for reporting progress to the user. It is the caller's responsibility to
 *            call done() on the given monitor. Accepts null, indicating that no progress should be reported and
 *            that the operation cannot be cancelled.
 * @throws CoreException
 */
private static void getFiles(IFileStore file, boolean recurse, List<IFileStore> list, boolean includeCloakedFiles,
		IProgressMonitor monitor) throws CoreException
{
	if (file == null)
	{
		return;
	}

	if (monitor != null)
	{
		Policy.checkCanceled(monitor);
	}

	if (isFolder(file, monitor))
	{
		IFileStore[] children = file.childStores(EFS.NONE, monitor);
		if (children != null)
		{
			SubMonitor progress = SubMonitor.convert(monitor, children.length);
			boolean addingFile;
			for (IFileStore child : children)
			{
				Policy.checkCanceled(progress);
				addingFile = false;
				if (includeCloakedFiles || !CloakingUtils.isFileCloaked(child))
				{
					list.add(child);
					addingFile = true;
				}

				if (recurse && addingFile && isFolder(child, progress))
				{
					getFiles(child, recurse, list, includeCloakedFiles, progress.newChild(1));
				}
			}
		}
	}
}