Java Code Examples for org.eclipse.core.resources.IContainer#getType()
The following examples show how to use
org.eclipse.core.resources.IContainer#getType() .
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: ModuleFile.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Returns whether a folder is on the public path of this module. The public paths include the * paths explicitly declared with <code><public></code> tags and all of their descendant * sub-folders. * * @param folder the folder to check * @return <code>true</code> if this folder is on a public path, and <code>false</code> otherwise */ public boolean isPublicPath(IFolder folder) { IFolder[] publicFolders = getFolders(getPublicPaths()); IContainer moduleContainer = getFile().getParent(); IContainer container = folder; // Walk up the ancestor chain looking for a public path matching this folder while (container.getType() == IResource.FOLDER) { // If we reach the module's container, we're done searching if (container.equals(moduleContainer)) { return false; } for (IFolder publicFolder : publicFolders) { if (container.equals(publicFolder)) { return true; } } container = container.getParent(); } return false; }
Example 2
Source File: JarFileExportOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void exportContainer(IProgressMonitor progressMonitor, IContainer container) throws InterruptedException { if (container.getType() == IResource.FOLDER && isOutputFolder((IFolder)container)) return; IResource[] children= null; try { children= container.members(); } catch (CoreException exception) { // this should never happen because an #isAccessible check is done before #members is invoked addWarning(Messages.format(JarPackagerMessages.JarFileExportOperation_errorDuringExport, BasicElementLabels.getPathLabel(container.getFullPath(), false)), exception); } if (children != null) { IJavaProject javaProject= JavaCore.create(container.getProject()); boolean isOnCP= javaProject.isOnClasspath(container); for (int i= 0; i < children.length; i++) { IResource child= children[i]; if (isOnCP || !javaProject.isOnClasspath(child) || isInternalJar(child)) exportElement(child, progressMonitor); } } }
Example 3
Source File: ProjectCustomizer.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Creates the PEAR folder structure * * @param container * an IProject * @throws PearException * if a problem occurs */ public static void createPearFolderStructure(IContainer container) throws PearException { try { // Create PEAR Folder Structure - Required Elements always ProjectCustomizer.createFolder(container, "metadata"); // Create PEAR Folder Structure - Optional Elements only for projects if (container.getType() == IResource.PROJECT) { ProjectCustomizer.createFolder(container, "src"); ProjectCustomizer.createFolder(container, "bin"); ProjectCustomizer.createFolder(container, "desc"); ProjectCustomizer.createFolder(container, "lib"); ProjectCustomizer.createFolder(container, "data"); ProjectCustomizer.createFolder(container, "doc"); ProjectCustomizer.createFolder(container, "conf"); ProjectCustomizer.createFolder(container, "resources"); } } catch (Throwable e) { PearException subEx = new PearException( "The PEAR folder structure could not be created properly.", e); throw subEx; } }
Example 4
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.9 */ protected boolean canClean(IContainer container, OutputConfiguration config) { if (container.getType() == IResource.PROJECT) return false; if (container.getType() == IResource.ROOT) return false; return config.isCanClearOutputDirectory(); }
Example 5
Source File: DialogUtils.java From typescript.java with MIT License | 5 votes |
public static ElementTreeSelectionDialog createFolderDialog(String initialFolder, final IProject project, final boolean showAllProjects, final boolean showFolder, Shell shell) { ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); FolderSelectionDialog dialog = new FolderSelectionDialog(shell, lp, cp); // dialog.setTitle(TypeScriptUIMessages.TernModuleOptionsPanel_selectPathDialogTitle); IContainer folder = StringUtils.isEmpty(initialFolder) ? project : (project != null ? project.getFolder(initialFolder) : ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(initialFolder))); if (folder != null && folder.exists()) { dialog.setInitialSelection(folder); } dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); ViewerFilter filter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IProject) { if (showAllProjects) return true; IProject p = (IProject) element; return (p.equals(project)); } else if (element instanceof IContainer) { IContainer container = (IContainer) element; if (showFolder && container.getType() == IResource.FOLDER) { return true; } return false; } return false; } }; dialog.addFilter(filter); return dialog; }
Example 6
Source File: WorkbenchResourceUtil.java From typescript.java with MIT License | 5 votes |
public static IFile findFileInContainerOrParent(IContainer container, IPath name) throws CoreException { if (container == null || container.getType() == IResource.ROOT) { // container is null, or it's workspace root. return null; } IFile file = container.getFile(name); if (file != null && file.exists()) { return file; } return findFileInContainerOrParent(container.getParent(), name); }
Example 7
Source File: GlobalRefreshResourceSelectionPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public String getText(Object element) { if(element instanceof IContainer) { IContainer c = (IContainer)element; if(c.getType() != IResource.PROJECT && resources.contains(c)) { return c.getFullPath().toString(); } } return workbenchProvider.getText(element); }
Example 8
Source File: StatusBarUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String formatResourceMessage(IResource element) { IContainer parent= element.getParent(); if (parent != null && parent.getType() != IResource.ROOT) return BasicElementLabels.getResourceName(element.getName()) + JavaElementLabels.CONCAT_STRING + BasicElementLabels.getPathLabel(parent.getFullPath(), false); else return BasicElementLabels.getResourceName(element.getName()); }
Example 9
Source File: JavaNavigatorLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String formatResourceMessage(IResource element) { IContainer parent = element.getParent(); if (parent != null && parent.getType() != IResource.ROOT) return BasicElementLabels.getResourceName(element.getName()) + JavaElementLabels.CONCAT_STRING + BasicElementLabels.getPathLabel(parent.getFullPath(), false); else return BasicElementLabels.getResourceName(element.getName()); }
Example 10
Source File: RouteResourceUtil.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public static void prepareFolder(IFolder folder) throws CoreException { IContainer parent = folder.getParent(); if (IResource.FOLDER == parent.getType()) { prepareFolder((IFolder) parent); } if (!folder.exists()) { folder.create(true, true, null); } }
Example 11
Source File: FileUtils.java From saros with GNU General Public License v2.0 | 4 votes |
/** * Makes sure that the parent directories of the given {@linkplain IResource resource} exist. * * @throws CoreException */ public static void mkdirs(final IResource resource) throws CoreException { final List<IFolder> parents = new ArrayList<IFolder>(); IContainer parent = resource.getParent(); while (parent != null && parent.getType() == IResource.FOLDER) { if (parent.exists()) break; parents.add((IFolder) parent); parent = parent.getParent(); } Collections.reverse(parents); for (final IFolder folder : parents) folder.create(false, true, null); }
Example 12
Source File: IO.java From spotbugs with GNU Lesser General Public License v2.1 | 3 votes |
/** * Recursively creates all folders needed, up to the project. Project must * already exist. * * @param resource * non null * @param monitor * non null * @throws CoreException */ private static void mkdirs(@Nonnull IResource resource, IProgressMonitor monitor) throws CoreException { IContainer container = resource.getParent(); if (container.getType() == IResource.FOLDER && !container.exists()) { if (!container.getParent().exists()) { mkdirs(container, monitor); } ((IFolder) container).create(true, true, monitor); } }
Example 13
Source File: ProjectCustomizer.java From uima-uimaj with Apache License 2.0 | 3 votes |
/** * Customizes an IProject with the UIMA nature using an InstallationDescriptor instance * * @param container * An IProject * @param insd * An InstallationDescriptor * @throws PearException * If a problem occurs */ public static void customizeProject(IContainer container, InstallationDescriptor insd) throws PearException { createPearFolderStructure(container); PearInstallationDescriptor.createInstallationDescriptor(container, insd, false); // only add UIMA Nature to projects if (container.getType() == IResource.PROJECT) { addUIMANature((IProject) container); } }