org.eclipse.core.internal.resources.File Java Examples
The following examples show how to use
org.eclipse.core.internal.resources.File.
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: AbstractFilePropertyTester.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
/** * Check whether selected file(s) matches set of extensions * * @param receiver selected file(s) * @param fileExtensions set of extensions to compare * @return true if selected file(s) matches at least one extensions, false otherwise. */ @SuppressWarnings({"unchecked", "restriction"}) protected boolean testSelectedFilesByExtensions(final Object receiver, final Set<String> fileExtensions) { boolean isValid = false; if (receiver instanceof Set) { final Set<Object> activeEditorSet = (Set<Object>) receiver; if (activeEditorSet.size() == 1 && activeEditorSet.iterator().next() instanceof TextSelection) { isValid = fileExtensions.contains(EclipseFileUtils.getActiveEditorFile().getFileExtension()); } } else if (receiver instanceof List) { final List<Object> fileList = (List<Object>) receiver; if( !fileList.isEmpty() ) { isValid = fileList.stream() .filter(file -> file instanceof File) .map(File.class::cast) .map(File::getFileExtension) .allMatch(fileExtensions::contains); } } return isValid; }
Example #2
Source File: RemoveConnectionHandler.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event) .getActivePage().getSelection(); if(selection instanceof TreeSelection) { TreeSelection treeSelection = (TreeSelection) selection; if(treeSelection.getFirstElement() instanceof File) { File file = (File) treeSelection.getFirstElement(); if(file.getFileExtension().equals("bib")){ WorkspaceBibTexEntry entry = wm.getWorkspaceBibTexEntryByUri(file.getLocationURI()); if(entry != null) { if(entry.getMendeleyFolder() != null) { // by setting the MendeleyFolder of a WorkspaceBibTexEntry to null, the connection will be removed entry.setMendeleyFolder(null); decoratorManager.update("de.tudresden.slr.model.mendeley.decorators.MendeleyOverlayDecorator"); } } } } } return null; }
Example #3
Source File: AbstractGWTPluginTestCase.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private static File createFile(IPath workspaceRelativeAbsPathOfFile, String contents) throws CoreException { // TODO: Convert to ResouceUtils.createFile Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace(); File file = (File) workspace.newResource(workspaceRelativeAbsPathOfFile, IResource.FILE); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(contents.getBytes()); file.create(byteArrayInputStream, false, null); JobsUtilities.waitForIdle(); return file; }
Example #4
Source File: MendeleyOverlayDecorator.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
@Override public String decorateText(String text, Object element) { /* * - decorates only .bib files * - if there is a WorkSpaceBibTexEntry for a .bib file that holds an instance of a MendeleyFolder, * the Folder Name will be placed next to the .bib file name */ if(element instanceof File) { File file = (File) element; if(file.getFileExtension().equals("bib")) { WorkspaceBibTexEntry entry = wm.getWorkspaceBibTexEntryByUri(file.getLocationURI()); if(entry != null) { if(entry.getMendeleyFolder() != null) { String folder_name = entry.getMendeleyFolder().getName(); //checks if .bib file is already decorated if(!text.contains("[" + folder_name + "]")) { String new_text = text + " [" + folder_name + "]"; return new_text; } } } // the main menu entry 'Mendeley -> Update Folders' must be disabled when no file is decorated updateMenuContribution(); } } return null; }
Example #5
Source File: AbstractGWTPluginTestCase.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public File addFileToTestProjSrcPkg(String fileName, String[] contentArray) throws CoreException { IPath pathToFile = getTestProject().getPath().append("src").append(fileName); File file = createFile(pathToFile, createString(contentArray)); return file; }