Java Code Examples for org.eclipse.core.resources.IFolder#members()
The following examples show how to use
org.eclipse.core.resources.IFolder#members() .
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: PlatformContentProvider.java From thym with Eclipse Public License 1.0 | 6 votes |
@Override public boolean hasChildren(Object element) { if (!(element instanceof IFolder)) { return false; } IFolder folder = (IFolder) element; if (folder.getProjectRelativePath().segmentCount() > 1) {// folder at the root of the project? return false; } try { return folder.members().length > 0; } catch (CoreException e) { HybridUI.log(IStatus.ERROR, "Error reading cordova platforms", e); } return false; }
Example 2
Source File: PlatformContentProvider.java From thym with Eclipse Public License 1.0 | 6 votes |
@Override public Object[] getChildren(Object parentElement) { if (!(parentElement instanceof IFolder)) { return new Object[0]; } IFolder folder = (IFolder) parentElement; if (folder.getProjectRelativePath().segmentCount() > 1) {// only platforms folder at the root of the project return new Object[0]; } List<HybridPlatformFolder> platformFolders = new ArrayList<>(); try { HybridProject project = HybridProject.getHybridProject(folder.getProject()); for (IResource member : folder.members()) { if (member instanceof IFolder) { IFolder platformFolder = (IFolder) member; platformFolders.add( new HybridPlatformFolder((IFolder) member, getPlatform(project, platformFolder.getName()))); } } } catch (CoreException e) { HybridUI.log(IStatus.ERROR, "Error reading cordova platforms", e); } return platformFolders.toArray(); }
Example 3
Source File: NewFileWizardPage.java From gama with GNU General Public License v3.0 | 6 votes |
private void addProjectTemplates(final Map<String, String> templates) { final IContainer container = findContainer(); if (container == null) { return; } final IProject project = container.getProject(); if (project == null) { return; } final IFolder folder = project.getFolder("templates"); if (!folder.exists()) { return; } try { for (final IResource resource : folder.members()) { final String name = resource.getName(); if (name.contains(".template")) { templates.put(name.replaceAll(".template", ""), resource.getProjectRelativePath().toString()); } } } catch (final CoreException e) { e.printStackTrace(); } }
Example 4
Source File: WebArtifactRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public List<T> getChildren() { refresh(); final List<T> result = new ArrayList<>(); final IFolder folder = getResource(); if(!folder.exists() || !folder.isAccessible()) { return result; } try { for (final IResource r : folder.members()) { if (!r.isHidden() && !r.getName().startsWith(".") && r instanceof IFolder) { IResource jsonDescriptorFile = ((IFolder) r).findMember(r.getName() + ".json"); if (jsonDescriptorFile != null && jsonDescriptorFile.exists()) { result.add(createRepositoryFileStore(r.getName())); } } } } catch (final CoreException e) { BonitaStudioLog.error(e); } return result; }
Example 5
Source File: SearchThread.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Gets the delegate components by IO types beginning at. * * @param beginFolder the begin folder * @return the delegate components by IO types beginning at */ // matchingAnalysisEngineDescriptions private void getDelegateComponentsByIOTypesBeginningAt(IFolder beginFolder) { if (m_bDieNow) { return; } try { for (int i = 0; i < beginFolder.members().length; i++) { testOneResource(beginFolder.members()[i]); } } catch (Exception ex) { ex.printStackTrace(); } }
Example 6
Source File: AbstractFolderRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public List<T> getChildren() { refresh(); final List<T> result = new ArrayList<>(); final IFolder folder = getResource(); try { for (final IResource r : folder.members()) { if (!r.isHidden() && !r.getName().startsWith(".")) { result.add(createRepositoryFileStore(r.getName())); } } } catch (final CoreException e) { BonitaStudioLog.error(e); } return result; }
Example 7
Source File: PackageExplorerContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the hierarchical packages inside a given folder. * @param folder The parent folder * @param result Collection where the resulting elements are added * @throws CoreException thrown when elements could not be accessed */ private void getHierarchicalPackagesInFolder(IFolder folder, Collection<Object> result) throws CoreException { IResource[] resources= folder.members(); for (int i= 0; i < resources.length; i++) { IResource resource= resources[i]; if (resource instanceof IFolder) { IFolder curr= (IFolder) resource; IJavaElement element= JavaCore.create(curr); if (element instanceof IPackageFragment) { if (fFoldPackages) { IPackageFragment fragment= (IPackageFragment) element; IPackageFragmentRoot root= (IPackageFragmentRoot) fragment.getParent(); element= getFolded(root.getChildren(), fragment); } result.add(element); } } } }
Example 8
Source File: Importer.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
private void addMembersOfFolderToClasspath(String path, IProgressMonitor monitor, IJavaProject javaProject) throws CoreException, JavaModelException { IFolder folder = javaProject.getProject().getFolder(path); if (folder != null && folder.exists()) { for (IResource res : folder.members()) { if (res.getFileExtension() != null && res.getFileExtension().equals("jar") && res.exists()) { // check if this Resource is on the classpath if (!javaProject.isOnClasspath(res)) { if (DEBUG) Activator.log("Adding library [" + res.getFullPath() + "] to classpath for project [" + javaProject.getProject().getName() + "]"); FixProjectsUtils.addToClassPath(res, IClasspathEntry.CPE_LIBRARY, javaProject, monitor); } } } } }
Example 9
Source File: HideEmptyRepository.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { RepositoryManager repositoryManager = RepositoryManager.getInstance(); IRepository repository = repositoryManager.getCurrentRepository(); if (repositoryManager.hasActiveRepository() && repository.isLoaded()) { IRepositoryStore<?> store = repositoryManager.getRepositoryStore(element).orElse(null); if (store != null) { try { IFolder resource = store.getResource(); if (resource.exists()) { IResource[] members = resource.members(); if (store instanceof WebWidgetRepositoryStore) { return Stream.of(members) .filter(r -> !r.getName().startsWith(".")) .anyMatch(r -> !r.getName().startsWith("pb")); } if (store instanceof WebPageRepositoryStore) { return Stream.of(members) .anyMatch(r -> !r.getName().startsWith(".")); } if (store instanceof WebFragmentRepositoryStore) { return Stream.of(members) .anyMatch(r -> !r.getName().startsWith(".")); } return members.length > 0; } } catch (CoreException e) { BonitaStudioLog.error(e); } } } return true; }
Example 10
Source File: SourceRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void findParentPackage(final IFolder folder, final List<IFile> sourceFiles) { try { for (final IResource r : folder.members()) { if (r instanceof IFile) { if (!sourceFiles.contains(r)) { sourceFiles.add((IFile) r); } } else if (r instanceof IFolder) { findParentPackage((IFolder) r, sourceFiles); } } } catch (final Exception e) { BonitaStudioLog.error(e); } }
Example 11
Source File: TmfCommonProjectElement.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Copy this model element to the destinationPath * * @param copySuppFiles * Whether to copy supplementary files or not * @param copyAsLink * Whether to copy as a link or not * @param destinationPath * The path where the element will be copied * @return the new Resource object * @since 3.3 */ public IResource copy(final boolean copySuppFiles, final boolean copyAsLink, IPath destinationPath) { /* Copy supplementary files first, only if needed */ if (copySuppFiles) { String newElementPath = getDestinationPathRelativeToParent(destinationPath); copySupplementaryFolder(newElementPath); } /* Copy the trace */ try { int flags = IResource.FORCE; if (copyAsLink) { flags |= IResource.SHALLOW; } IResource trace = ResourceUtil.copyResource(getResource(), destinationPath, flags, null); /* Delete any bookmarks file found in copied trace folder */ if (trace instanceof IFolder) { IFolder folderTrace = (IFolder) trace; for (IResource member : folderTrace.members()) { String traceTypeId = TmfTraceType.getTraceTypeId(member); if (ITmfEventsEditorConstants.TRACE_INPUT_TYPE_CONSTANTS.contains(traceTypeId) || ITmfEventsEditorConstants.EXPERIMENT_INPUT_TYPE_CONSTANTS.contains(traceTypeId)) { member.delete(true, null); } } } return trace; } catch (CoreException e) { Activator.getDefault().logError("Error copying " + getName(), e); //$NON-NLS-1$ } return null; }
Example 12
Source File: TmfCommonProjectElement.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Returns the supplementary resources under the trace supplementary folder. * * @return array of resources under the trace supplementary folder. */ public IResource[] getSupplementaryResources() { IFolder supplFolder = getTraceSupplementaryFolder(getSupplementaryFolderPath()); if (supplFolder.exists()) { try { return supplFolder.members(); } catch (CoreException e) { Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ } } return new IResource[0]; }
Example 13
Source File: DropAdapterAssistant.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Cleanup bookmarks file in copied trace */ private static void cleanupBookmarks(IPath path) { IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path); if (folder.exists()) { try { for (IResource member : folder.members()) { if (ITmfEventsEditorConstants.TRACE_INPUT_TYPE_CONSTANTS.contains(TmfTraceType.getTraceTypeId(member))) { member.delete(true, null); } } } catch (CoreException e) { TraceUtils.displayErrorMsg(e); } } }
Example 14
Source File: NoPackageContainingFoldersFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean containsPackage(IFolder folder) throws CoreException { IJavaElement element= JavaCore.create(folder); if (element instanceof IPackageFragment) return true; IResource[] resources= folder.members(); for (int i= 0; i < resources.length; i++) { if (resources[i] instanceof IFolder && containsPackage((IFolder)resources[i])) return true; } return false; }
Example 15
Source File: NekModel.java From ice with Eclipse Public License 1.0 | 5 votes |
/** * This operation returns the list of reafiles in the * "Nek5000_Model_Builder" folder of the project space, or null if the * folder does not exist or there are no files. * * @return */ private ArrayList<String> getProjectFiles() { // Local Declarations ArrayList<String> files = new ArrayList<String>(); // Add files from the project space to the Form if (project != null) { try { // Get the Nek folder IFolder nekFolder = getPreferencesDirectory(); project.refreshLocal(IResource.DEPTH_INFINITE, null); // If it exists, get any existing problem files out of it if (nekFolder.exists()) { // Get any resources that exist IResource[] resources = nekFolder.members(); // Add them to the list of input files for (IResource resource : resources) { // Dump the name of this file if debugging is enabled logger.debug("NekModel Message: " + "Found file " + resource.getName() + "."); // See if the resource is a file with a .rea extension. if (resource.getType() == IResource.FILE && resource.getProjectRelativePath() .lastSegment().contains(".rea")) { files.add(resource.getName()); } } } else { // Otherwise, return a null list so that the caller knows // there are no resources. return null; } } catch (CoreException e) { logger.error(getClass().getName() + " Exception!", e); } } return files; }
Example 16
Source File: AddIgnoredPatternCommand.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @param resources */ private void broadcastNestedFolders(IResource[] resources) { for (int i = 0; i < resources.length;i++) { if (resources[i].getType() == IResource.FOLDER) { IFolder folder = (IFolder) resources[i]; try { IResource[] children = folder.members(true); SVNProviderPlugin.broadcastSyncInfoChanges(children, false); broadcastNestedFolders(children); } catch (CoreException e1) { } } } }
Example 17
Source File: BuildInstruction.java From n4js with Eclipse Public License 1.0 | 5 votes |
private void deleteEmptyDirectories(IFolder folder, IProgressMonitor progressMonitor) throws CoreException { for (IResource member : folder.members()) { if (member instanceof IFolder) { deleteEmptyDirectories((IFolder) member, progressMonitor); } } if (folder.members().length == 0) { folder.delete(true, progressMonitor); } }
Example 18
Source File: SavedModuleContributionItem.java From tlaplus with MIT License | 4 votes |
protected IContributionItem[] getContributionItems() { /* * Does nothing if the active editor is not a model editor. The * following code gets the config file for the active model editor (if * it is the active editor), gets the model folder for that config, * iterates through all members of the model folder, adding a * contribution item for each member that has extension .tla and is not * TE.tla or MC.tla. */ IEditorPart editor = UIHelper.getActiveEditor(); if (editor instanceof ModelEditor) { IFolder modelFolder = ((ModelEditor) editor).getModel().getTargetDirectory(); if (modelFolder != null && modelFolder.exists()) { try { /* * The collection of command contribution items that will * populate the menu and contain the command to be run when * selected. */ final List<IContributionItem> contributions = new ArrayList<IContributionItem>(); // get all resources in the model folder IResource[] members = modelFolder.members(); for (int i = 0; i < members.length; i++) { /* * We add to the menu an option to open every file that * has exists, has extension .tla, and is not the TE or * MC file. * * On Nov 2011, DR added a null check to members[i].getFileExtension() which * can return null for directories. */ if (members[i].exists() && members[i].getFileExtension() != null && members[i].getFileExtension().equals(ResourceHelper.TLA_EXTENSION) && !members[i].getName().equals(TLAConstants.Files.MODEL_CHECK_TLA_FILE) && !members[i].getName().equals(ModelHelper.TE_FILE_TLA)) { Map<String, String> parameters = new HashMap<String, String>(1); parameters.put(OpenSavedModuleHandler.PARAM_MODULE_PATH, members[i].getRawLocation() .toPortableString()); contributions.add(new CommandContributionItem(new CommandContributionItemParameter(UIHelper .getActiveWindow(), "toolbox.command.model.open.savedModule.", OpenSavedModuleHandler.COMMAND_ID, parameters, null, null, null, members[i] .getName(), null, "Opens the version saved in the last run of TLC.", SWT.PUSH, null, true))); } } return (IContributionItem[]) contributions.toArray(new IContributionItem[contributions.size()]); } catch (CoreException e) { TLCUIActivator.getDefault().logError("Error getting members of model folder " + modelFolder, e); } } } return new IContributionItem[0]; }
Example 19
Source File: WebAppLaunchShortcutStrategy.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
@Override public String generateUrl(IResource selection, boolean isExternal) throws CoreException { IProject project = selection.getProject(); WebAppUtilities.verifyIsWebApp(project); IFolder warFolder = WebAppUtilities.getWarSrc(project); if (warFolder == null) { throw new CoreException(new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Couldn't find WAR folder.")); } if (isExternal) { return getUrlFromUser(selection, isExternal); } if (ResourceUtils.hasJspOrHtmlExtension(selection)) { int warSegments = warFolder.getFullPath().segmentCount(); IPath pathRelativeToWar = selection.getFullPath().removeFirstSegments( warSegments); return pathRelativeToWar.toString(); } List<IResource> candidates = new ArrayList<IResource>(); for (IResource member : warFolder.members()) { if (ResourceUtils.hasJspOrHtmlExtension(member)) { candidates.add(member); } } if (candidates.isEmpty()) { // NOTE: This can happen for a gae-only project that only has a servlet. return ""; } else if (candidates.size() == 1) { return candidates.get(0).getName(); } else { return getUrlFromUser(selection, isExternal); } }
Example 20
Source File: DiagramRepositoryStore.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public List<DiagramFileStore> getRecentChildren(final int nbResult) { if (!getResource().exists()) { return Collections.emptyList(); } refresh(); final List<DiagramFileStore> result = new ArrayList<>(); final List<IResource> resources = new ArrayList<>(); final IFolder folder = getResource(); try { for (final IResource r : folder.members()) { if (r.getFileExtension() != null && getCompatibleExtensions().contains( r.getFileExtension())) { resources.add(r); } } } catch (final CoreException e) { BonitaStudioLog.error(e); } Collections.sort(resources, new Comparator<IResource>() { @Override public int compare(final IResource arg0, final IResource arg1) { final long lastModifiedArg1 = arg1.getLocation().toFile() .lastModified(); final long lastModifiedArg0 = arg0.getLocation().toFile() .lastModified(); return Long.valueOf(lastModifiedArg1).compareTo( Long.valueOf(lastModifiedArg0)); } }); for (int i = 0; i < nbResult; i++) { if (resources.size() > i) { result.add(createRepositoryFileStore(resources.get(i).getName())); } } return result; }