Java 类org.eclipse.core.resources.IContainer 实例源码

项目:n4js    文件:ModuleSpecifierSelectionDialog.java   
/**
 * Create the dialog.
 *
 * <p>
 * Note: The model should have a valid source folder path as this is the root folder for this browse dialog. If the
 * source folder path doesn't exist yet this dialog will be empty.
 * </p>
 *
 * @param parent
 *            Parent Shell  
 * @param sourceFolder
 *            The source folder to browse in for modules and module folders
 *
 *
 */
public ModuleSpecifierSelectionDialog(Shell parent, IPath sourceFolder) {
    super(parent, MODULE_ELEMENT_NAME, CREATE_FOLDER_LABEL);
    this.setTitle("Select a module");

    this.setInputValidator(inputValidator);

    IPath parentPath = sourceFolder.removeLastSegments(1);
    IContainer sourceFolderParent = containerForPath(parentPath);
    IFolder workspaceSourceFolder = workspaceRoot
            .getFolder(sourceFolder);

    // Use parent of source folder as root to show source folder itself in the tree
    this.treeRoot = sourceFolderParent;

    this.sourceFolder = workspaceSourceFolder;
    this.addFilter(new ModuleFolderFilter(this.sourceFolder.getFullPath()));

    this.setAutoExpandLevel(2);
    // Show the status line above the buttons
    this.setStatusLineAboveButtons(true);
}
项目:VerveineC-Cpp    文件:FileUtil.java   
private static void mkdirs(IFolder destPath) {
    IContainer parent = destPath.getParent(); 
    if (! parent.exists()) {
        if (parent instanceof IFolder) {
            mkdirs((IFolder) parent);
        }
        else if (parent instanceof IProject) {
            mkdirs( ((IProject)parent).getFolder(".") );
        }
    }
    try {
        destPath.create(/*force*/true, /*local*/true, Constants.NULL_PROGRESS_MONITOR);
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
项目:n4js    文件:CleanInstruction.java   
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
        throws CoreException {
    IContainer container = getContainer(aProject, config.getOutputDirectory());
    if (!container.exists()) {
        return;
    }
    if (config.isCanClearOutputDirectory()) {
        for (IResource resource : container.members()) {
            resource.delete(IResource.KEEP_HISTORY, monitor);
        }
    } else if (config.isCleanUpDerivedResources()) {
        List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
        for (IFile iFile : resources) {
            iFile.delete(IResource.KEEP_HISTORY, monitor);
        }
    }
}
项目:n4js    文件:N4JSBuilderParticipant.java   
@Override
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject,
        Collection<OutputConfiguration> outputConfigurations) throws CoreException {

    if (builtProject instanceof ExternalProject) {
        return emptyMap();
    }

    Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
    for (OutputConfiguration config : outputConfigurations) {
        if (config.isCleanUpDerivedResources()) {
            List<IMarker> markers = Lists.newArrayList();
            for (IContainer container : getOutputs(builtProject, config)) {
                Iterables.addAll(
                        markers,
                        getDerivedResourceMarkers().findDerivedResourceMarkers(container,
                                getGeneratorIdProvider().getGeneratorIdentifier()));
            }
            generatorMarkers.put(config, markers);
        }
    }
    return generatorMarkers;
}
项目:n4js    文件:TestConfigurationConverter.java   
/**
 * Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see TestConfiguration#readPersistentValues()
 */
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig) {
    try {
        final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
                .getLaunchConfigurations(type);

        for (ILaunchConfiguration config : configs) {
            if (equals(testConfig, config))
                return config;
        }

        final IContainer container = null;
        final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName());

        workingCopy.setAttributes(testConfig.readPersistentValues());

        return workingCopy.doSave();
    } catch (Exception e) {
        throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e);
    }
}
项目:n4js    文件:RunConfigurationConverter.java   
/**
 * Converts a {@link RunConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see RunConfiguration#readPersistentValues()
 */
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, RunConfiguration runConfig) {
    try {
        final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
                .getLaunchConfigurations(type);

        for (ILaunchConfiguration config : configs) {
            if (equals(runConfig, config))
                return config;
        }

        final IContainer container = null;
        final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, runConfig.getName());

        workingCopy.setAttributes(runConfig.readPersistentValues());

        return workingCopy.doSave();
    } catch (Exception e) {
        throw new WrappedException("could not convert N4JS RunConfiguration to Eclipse ILaunchConfiguration", e);
    }
}
项目:ec4e    文件:NewEditorConfigWizard.java   
/**
 * Returns the content of the .editorconfig file to generate.
 *
 * @param container
 *
 * @return the content of the .editorconfig file to generate.
 */
private InputStream openContentStream(IContainer container) {
    IPreferenceStore store = EditorsUI.getPreferenceStore();
    boolean spacesForTabs = store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
    int tabWidth = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
    String lineDelimiter = getLineDelimiter(container);
    String endOfLine = org.ec4j.core.model.PropertyType.EndOfLineValue.ofEndOfLineString(lineDelimiter).name();

    StringBuilder content = new StringBuilder("# EditorConfig is awesome: http://EditorConfig.org");
    content.append(lineDelimiter);
    content.append(lineDelimiter);
    content.append("[*]");
    content.append(lineDelimiter);
    content.append("indent_style = ");
    content.append(spacesForTabs ? "space" : "tab");
    content.append(lineDelimiter);
    content.append("indent_size = ");
    content.append(tabWidth);
    if (endOfLine != null) {
        content.append(lineDelimiter);
        content.append("end_of_line = ");
        content.append(endOfLine);
    }

    return new ByteArrayInputStream(content.toString().getBytes());
}
项目:neoscada    文件:LaunchShortcut.java   
private void addJvmOptions ( final ILaunchConfigurationWorkingCopy cfg, final Profile profile, final IContainer container ) throws CoreException
{
    final List<String> args = new LinkedList<> ();

    args.addAll ( profile.getJvmArguments () );

    for ( final SystemProperty p : profile.getProperty () )
    {
        addSystemProperty ( profile, args, p.getKey (), p.getValue (), p.isEval () );
    }

    for ( final Map.Entry<String, String> entry : getInitialProperties ().entrySet () )
    {
        addSystemProperty ( profile, args, entry.getKey (), entry.getValue (), false );
    }

    final IFile dataJson = container.getFile ( new Path ( "data.json" ) ); //$NON-NLS-1$
    if ( dataJson.exists () )
    {
        addJvmArg ( args, "org.eclipse.scada.ca.file.provisionJsonUrl", escapeArgValue ( dataJson.getLocation ().toFile ().toURI ().toString () ) ); //$NON-NLS-1$
    }

    cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, StringHelper.join ( args, "\n" ) );
    cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, StringHelper.join ( profile.getArguments (), "\n" ) );
}
项目:neoscada    文件:RecipeHelper.java   
public static void processFile ( final IContainer parent, final Definition definition, final Profile profile, final IProgressMonitor monitor ) throws Exception
{
    monitor.beginTask ( makeJobLabel ( definition, profile ), 100 );

    final IFolder output = parent.getFolder ( new Path ( "output" ) ); //$NON-NLS-1$
    if ( output.exists () )
    {
        output.delete ( true, new SubProgressMonitor ( monitor, 9 ) );
    }
    output.create ( true, true, new SubProgressMonitor ( monitor, 1 ) );

    final Builder builder = new Builder ( definition, profile );
    final Recipe recipe = builder.build ();

    try
    {
        final Map<String, Object> initialContent = new HashMap<String, Object> ();
        initialContent.put ( "output", output ); //$NON-NLS-1$

        recipe.execute ( initialContent, new SubProgressMonitor ( monitor, 90 ) );
    }
    finally
    {
        monitor.done ();
    }
}
项目:gw4e.project    文件:GraphWalkerFacade.java   
/**
 * Retrieve the graph models contained in the container
 * 
 * @param container
 * @param models
 * @throws CoreException
 */
public static void getGraphModels(IContainer container, List<IFile> models) throws CoreException {
    if (!container.exists())
        return;
    IResource[] members = container.members();
    for (IResource member : members) {
        if (member instanceof IContainer)
            getGraphModels((IContainer) member, models);
        else if (member instanceof IFile) {
            IFile file = (IFile) member;
            if (PreferenceManager.isGraphModelFile(file))
                models.add(file);
            if (PreferenceManager.isGW3ModelFile(file))
                models.add(file);
            if (PreferenceManager.isJSONModelFile(file))
                models.add(file);

        }
    }
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * Create a file in a folder with the specified name and content
 * 
 * @param fullpath
 * @param filename
 * @param content
 * @throws CoreException
 * @throws InterruptedException
 */
public static IFile createFileDeleteIfExists(String fullpath, String filename, String content,
        IProgressMonitor monitor) throws CoreException, InterruptedException {
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
    subMonitor.setTaskName("Create file delete if it exists " + fullpath);
    IFile newFile;
    try {
        IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
        IContainer container = (IContainer) wroot.findMember(new Path(fullpath));
        newFile = container.getFile(new Path(filename));
        if (newFile.exists()) {
            JDTManager.rename(newFile, new NullProgressMonitor());
            newFile.delete(true, new NullProgressMonitor());
        }
        subMonitor.split(30);
        byte[] source = content.getBytes(Charset.forName("UTF-8"));
        newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor());
        subMonitor.split(70);
    } finally {
        subMonitor.done();
    }
    return newFile;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param container
 * @param path
 * @return
 * @throws CoreException
 */
private static IFile processContainer(IContainer container, String path) throws CoreException {
    IResource[] members = container.members();
    for (IResource member : members) {
        if (member instanceof IContainer) {
            IFile file = processContainer((IContainer) member, path);
            if (file != null) {
                IPath p = ResourceManager.getPathWithinPackageFragment(file); // avoid
                                                                                // file
                                                                                // within
                                                                                // classes
                                                                                // directory
                if (p != null)
                    return file;
            }
        } else if (member instanceof IFile) {
            IFile ifile = (IFile) member;
            if (ifile.getFullPath().toString().endsWith(path)) {
                return ifile;
            }
        }
    }
    return null;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param container
 * @param files
 * @throws CoreException
 */
public static void getAllJUnitResultFiles(String projectName, List<IFile> files) throws CoreException {
    if (projectName == null)
        return;
    IContainer container = ResourceManager.getProject(projectName);
    container.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    IResource[] members = container.members();
    for (IResource member : members) {
        if (member instanceof IFile) {
            IFile file = (IFile) member;
            if (isJUnitResultFile(file)) {
                files.add(file);
            }
        }
    }
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param folder
 * @param filetorefresh
 * @return
 * @throws CoreException
 * @throws InterruptedException
 */
public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh)
        throws CoreException, InterruptedException {
    final IResource buildfile = find(folder, filetorefresh);
    Job job = new WorkspaceJob("Refresh folders") {
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            if (buildfile != null && buildfile.exists()) {
                try {
                    buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                } catch (CoreException e) {
                    ResourceManager.logException(e);
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setUser(true);
    job.schedule();

    return buildfile;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * Process recursively the containers until we found a resource with the
 * specified path
 * 
 * @param container
 * @param path
 * @return
 * @throws CoreException
 */
private static boolean resourceExistsIn(IContainer container, IPath path) throws CoreException {
    boolean found = false;
    IResource[] members = container.members();
    for (IResource member : members) {
        if (member instanceof IContainer) {

            found = resourceExistsIn((IContainer) member, path);
            if (found)
                break;
        } else if (member instanceof IFile) {
            IFile file = (IFile) member;

            if (path.equals(file.getFullPath()))
                return true;
        }
    }
    return found;
}
项目:gw4e.project    文件:BuildPoliciesCache.java   
/**
 * @param projectName
 * @param container
 * @param monitor
 */
private static void deleteCache(String cachename, IContainer container, IProgressMonitor monitor) {
    try {
        IResource[] members = container.members();
        for (IResource member : members) {
            if (member instanceof IContainer) {
                deleteCache(cachename, (IContainer) member, monitor);
            } else if (member instanceof IFile) {
                IFile file = (IFile) member;
                if (cachename.equals(file.getName())) {
                    file.delete(true, monitor);
                }
            }
        }
    } catch (CoreException e) {
        ResourceManager.logException(e);
    }
}
项目:gw4e.project    文件:GW4EProject.java   
public static void cleanWorkspace() throws CoreException {
    IProject[] projects = getRoot().getProjects();
    deleteProjects(projects);
    IProject[] otherProjects = getRoot().getProjects(IContainer.INCLUDE_HIDDEN);
    deleteProjects(otherProjects);

    ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager()
            .getLaunchConfigurationType(GW4ELaunchShortcut.GW4ELAUNCHCONFIGURATIONTYPE);
    ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
            .getLaunchConfigurations(configType);
    for (int i = 0; i < configs.length; i++) {
        ILaunchConfiguration config = configs[i];
        config.delete();
    }

}
项目:gw4e.project    文件:ImportHelper.java   
public static void copyFiles(File srcFolder, IContainer destFolder) throws CoreException, FileNotFoundException {
    for (File f : srcFolder.listFiles()) {
        if (f.isDirectory()) {
            IFolder newFolder = destFolder.getFolder(new Path(f.getName()));
            newFolder.create(true, true, null);
            copyFiles(f, newFolder);
        } else {
            IFile newFile = destFolder.getFile(new Path(f.getName()));
            InputStream in = new FileInputStream(f);
            try {
                newFile.create(in, true, null);
            } finally {
                try {
                    if (in != null)
                        in.close();
                } catch (IOException e) {
                }
            }
        }
    }
}
项目:n4js    文件:AbstractBuilderParticipantTest.java   
/***/
protected void createParentFolder(IFolder folder) throws CoreException {
    IContainer parent = folder.getParent();
    if (parent instanceof IFolder) {
        IFolder parentFolder = (IFolder) parent;
        if (!parentFolder.exists()) {
            createParentFolder(parentFolder);
            parentFolder.create(true, true, null);
        }
    }
}
项目:Tarski    文件:LoadCompletionProcessor.java   
private void findAllEMFFiles(final IContainer container) throws CoreException {
  final IResource[] members = container.members();
  for (final IResource member : members) {
    if (member instanceof IContainer) {
      if (member.isAccessible()) {
        findAllEMFFiles((IContainer) member);
      }
    } else if (member instanceof IFile) {
      final IFile file = (IFile) member;
      if (file.getFileExtension().equals("ecore")) {
        allEcoreFiles.put(file.getName(), file);
      }
    }
  }
}
项目:n4js    文件:ModuleSpecifierSelectionDialog.java   
@Override
protected void computeResult() {

    Object selection = treeViewer.getStructuredSelection().getFirstElement();

    if (selection == null) {
        return;
    }

    String moduleName = elementNameInput.getText();
    String moduleFileExtension = elementNameInput.getSuffix();

    // For selected files where the element name input equals the selected file
    if (selection instanceof IFile
            && ((IFile) selection).getFullPath().removeFileExtension().lastSegment().equals(moduleName)) {
        // Use the selected file's path as result
        IPath fileSpec = sourceFolderRelativePath((IResource) selection);
        this.setResult(Arrays.asList(fileSpec.toString()));
        return;
    } else if (selection instanceof IResource) {
        // For files with different element name input value, use their container as basepath
        if (selection instanceof IFile) {
            selection = ((IFile) selection).getParent();
        }

        IFile moduleFile = ((IContainer) selection).getFile(new Path(moduleName + moduleFileExtension));
        this.setResult(
                Arrays.asList(moduleFile.getFullPath().makeRelativeTo(sourceFolder.getFullPath()).toString()));

        return;
    } else {
        updateError("Invalid selection type.");
    }
}
项目:Hydrograph    文件:ExternalSchemaFileSelectionDialog.java   
public Object[] getChildren(Object element) {
    if (element instanceof IContainer) {
        try {
            return ((IContainer) element).members();
        }
        catch (CoreException e) {
        }
    }
    return null;
}
项目:ec4e    文件:NewEditorConfigWizard.java   
private static String getLineDelimiter(IContainer file) {
    String lineDelimiter = getLineDelimiterPreference(file);
    if (lineDelimiter == null) {
        lineDelimiter = System.getProperty("line.separator");
    }
    if (lineDelimiter != null) {
        return lineDelimiter;
    }
    return "\n";
}
项目:n4js    文件:WorkspaceWizardPage.java   
/**
 * This method should be invoked whenever source folder or project value change, to update the proposal contexts for
 * the field source folder and module specifier
 */
private void updateProposalContext() {
    IPath projectPath = model.getProject();
    IPath sourceFolderPath = model.getSourceFolder();

    // Early exit for empty project value
    if (projectPath.isEmpty()) {
        sourceFolderContentProposalAdapter.setContentProposalProvider(null);
        moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
        return;
    }

    IProject project = ResourcesPlugin.getWorkspace().getRoot()
            .getProject(projectPath.toString());

    if (null == project || !project.exists()) {
        // Disable source folder and module specifier proposals
        sourceFolderContentProposalAdapter.setContentProposalProvider(null);
        moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
    } else {
        // Try to retrieve the source folder and if not specified set it to null
        IContainer sourceFolder = sourceFolderPath.segmentCount() != 0 ? project.getFolder(sourceFolderPath) : null;

        // If the project exists, enable source folder proposals
        sourceFolderContentProposalAdapter
                .setContentProposalProvider(sourceFolderContentProviderFactory.createProviderForProject(project));

        if (null != sourceFolder && sourceFolder.exists()) {
            // If source folder exists as well enable module specifier proposal
            moduleSpecifierContentProposalAdapter.setContentProposalProvider(
                    moduleSpecifierContentProviderFactory.createProviderForPath(sourceFolder.getFullPath()));
        } else {
            // Otherwise disable module specifier proposals
            moduleSpecifierContentProposalAdapter.setContentProposalProvider(null);
        }
    }
}
项目:n4js    文件:SelectionFilesCollector.java   
/** Dispatches based on provided element (can call itself recursively). */
private void collectRelevantFiles(Object element, Set<IFile> collected) {
    // order of type check matters!
    if (element instanceof IWorkingSet) {
        collectIAdaptable((IWorkingSet) element, collected);
    } else if (element instanceof IContainer) {
        collectResource((IContainer) element, collected);
    } else if (element instanceof IFile) {
        collectIFile((IFile) element, collected);
    } else {
        LOGGER.warn("Files collector ignores " + element.getClass().getName() + ".");
    }
}
项目:n4js    文件:SelectionFilesCollector.java   
private void collectResource(IContainer container, Set<IFile> collected) {
    try {
        IResource[] resources = container.members(IContainer.EXCLUDE_DERIVED);
        for (IResource resource : resources) {
            collectRelevantFiles(resource, collected);
        }
    } catch (CoreException c) {
        LOGGER.warn("Error while collecting files", c);
    }
}
项目:n4js    文件:N4JSEclipseModel.java   
@Override
protected IN4JSEclipseSourceContainer createProjectN4JSSourceContainer(N4JSProject project,
        SourceFragmentType type, String relativeLocation) {

    N4JSEclipseProject casted = (N4JSEclipseProject) project;
    IProject eclipseProject = casted.getProject();
    final IContainer container;
    if (".".equals(relativeLocation)) {
        container = eclipseProject;
    } else {
        container = eclipseProject.getFolder(relativeLocation);
    }
    return new EclipseSourceContainer(casted, type, container);
}
项目:n4js    文件:N4JSEclipseModel.java   
private boolean pathStartsWithFolder(IPath fullPath, IContainer container) {
    IPath containerPath = container.getFullPath();
    int maxSegments = containerPath.segmentCount();
    if (fullPath.segmentCount() >= maxSegments) {
        for (int j = 0; j < maxSegments; j++) {
            if (!fullPath.segment(j).equals(containerPath.segment(j))) {
                return false;
            }
        }
        return true;
    }
    return false;
}
项目:ec4e    文件:ContainerResourcePath.java   
@Override
public ResourcePath getParent() {
    if (container.getType() == IResource.PROJECT) {
        // Stop the search of  '.editorconfig' files in the parent container
        return null;
    }
    IContainer parent = container.getParent();
    return parent == null ? null : new ContainerResourcePath(parent);
}
项目:n4js    文件:AbstractExportToSingleFileWizardPage.java   
/**
 * Returns the name of a {@link IProject} with a location that includes targetDirectory. Returns null if there is no
 * such {@link IProject}.
 *
 * @param targetDirectory
 *            the path of the directory to check.
 * @return the overlapping project name or <code>null</code>
 */
private String getOverlappingProjectName(String targetDirectory) {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IPath testPath = new Path(targetDirectory);
    IContainer[] containers = root.findContainersForLocationURI(testPath.makeAbsolute().toFile().toURI());
    if (containers.length > 0) {
        return containers[0].getProject().getName();
    }
    return null;
}
项目:ide-plugins    文件:ProjectUtils.java   
public ProjectUtils(IContainer project) {
    this.project = project;

    if (project != null && getGradleBuildFile(project) != null) {
        configure();
    }

}
项目:ide-plugins    文件:ProjectUtils.java   
public static IFile getGradleBuildFile(IContainer project) {
    IResource resource = project.findMember("build.gradle");
        if (resource != null && resource.exists()) {
            return (IFile) resource;
        }
        return null;
}
项目:time4sys    文件:NewModelWizard.java   
/**
 * Compute the name of the new Time4Sys model.
 *
 * @param selectedResource
 *            Selected resource
 * @return Name of the new Time4Sys model
 */
private String getNewModelName(IResource selectedResource) {
    final String defaultModelBaseFilename = "NewProject";
    String modelFilename = defaultModelBaseFilename + ".time4sys"; //$NON-NLS-1$
    for (int i = 1; ((IContainer) selectedResource).findMember(modelFilename) != null; ++i) {
        modelFilename = defaultModelBaseFilename + i + ".time4sys"; //$NON-NLS-1$
    }
    return modelFilename;
}
项目:neoscada    文件:ClientTemplate.java   
private void addResource ( final IProject project, final String name, final InputStream stream, final IProgressMonitor monitor ) throws CoreException
{
    try
    {
        final String[] toks = name.split ( "\\/" ); //$NON-NLS-1$
        IContainer container = project;
        for ( int i = 0; i < toks.length - 1; i++ )
        {
            final IFolder folder = container.getFolder ( new Path ( toks[i] ) );
            if ( !folder.exists () )
            {
                folder.create ( true, true, null );
            }
            container = folder;
        }
        final IFile file = project.getFile ( name );
        if ( file.exists () )
        {
            file.setContents ( stream, IResource.FORCE, monitor );
        }
        else
        {
            file.create ( stream, true, monitor );
        }
    }
    finally
    {
        try
        {
            stream.close ();
        }
        catch ( final IOException e )
        {
        }
    }
    monitor.done ();
}
项目:pgcodekeeper    文件:PgUIDumpLoader.java   
public static int countFiles(IContainer container) throws CoreException {
    int[] count = new int[1];
    container.accept(p -> {
        if (p.getType() == IResource.FILE) {
            ++count[0];
        }
        return true;
    }, 0);
    return count[0];
}
项目:xmontiarc    文件:DesignerHelper.java   
private static List<String> loadModels(IContainer container) throws CoreException {
    List<String> files = new ArrayList<String>();
    IResource[] members = container.members();
    for (IResource member : members) {
        if (member instanceof IContainer) {
            files.addAll(loadModels((IContainer) member));
        } else if (member instanceof IFile) {
            if (member.getFileExtension() != null && member.getFileExtension().equals("xmontiarc")) {
                String path = member.getFullPath().toOSString();
                files.add(path);
            }
        }
    }
    return files;
}
项目:Tarski    文件:LoadCompletionProcessor.java   
private void findAllXMIFiles(final IContainer container) throws CoreException {
  final IResource[] members = container.members();
  for (final IResource member : members) {
    if (member instanceof IContainer) {
      if (member.isAccessible()) {
        findAllXMIFiles((IContainer) member);
      }
    } else if (member instanceof IFile) {
      final IFile file = (IFile) member;
      allFiles.put(file.getName(), file);
    }
  }
}
项目:neoscada    文件:ProfilesContribution.java   
private void addDefinition ( final List<IContributionItem> items, final IContainer parent, final Definition def )
{
    items.add ( new DefinitionContributionItem ( parent, def ) );
    for ( final Profile p : def.getProfiles () )
    {
        items.add ( new ProfileContributionItem ( parent, def, p ) );
    }
}
项目:gw4e.project    文件:FolderSelectionGroup.java   
/**
 * @param container
 * @throws CoreException 
 */
public void setContainerFullPath(IProject project, IPath path) throws CoreException {
    IResource container = ResourceManager.getResource(path.toString());
    if (container==null)
        container = ResourceManager.ensureFolder(project, path.removeFirstSegments(1).toString(), new NullProgressMonitor());
    typeTreeViewer.refresh();
    selectedContainer=(IContainer)container;
    typeTreeViewer.expandToLevel(path, 1);
    typeTreeViewer.setSelection(new StructuredSelection(selectedContainer), true);
    fireEvent ();
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param container
 * @param files
 * @throws CoreException
 */
public static void getAllGraphFiles(IContainer container, List<IFile> files) throws CoreException {
    IResource[] members = container.members();
    for (IResource member : members) {
        if (member instanceof IContainer) {
            getAllGraphFiles((IContainer) member, files);
        } else if (member instanceof IFile) {
            IFile file = (IFile) member;
            if (PreferenceManager.isGraphModelFile(file))
                files.add(file);
        }
    }
}