当前位置: 首页>>代码示例>>Java>>正文


Java IContainer.getFolder方法代码示例

本文整理汇总了Java中org.eclipse.core.resources.IContainer.getFolder方法的典型用法代码示例。如果您正苦于以下问题:Java IContainer.getFolder方法的具体用法?Java IContainer.getFolder怎么用?Java IContainer.getFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.resources.IContainer的用法示例。


在下文中一共展示了IContainer.getFolder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processFile

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
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 ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:RecipeHelper.java

示例2: copyFiles

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
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) {
				}
			}
		}
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:22,代码来源:ImportHelper.java

示例3: doFinish

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
private void doFinish(IPath containerPath, String[] path, IProgressMonitor monitor) throws CoreException {
	monitor.beginTask("Creating package " + String.join(".", path), path.length);
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

	IResource resource = root.findMember(containerPath);
	if (!resource.exists() || !(resource instanceof IContainer)) {
		throwCoreException("Container \"" + containerPath + "\" does not exist.");
	}

	IContainer container = (IContainer) resource;
	for(int i = 0; i < path.length; i++) {
		Path p = new Path(path[i]);
		final IFolder folder = container.getFolder(p);
		if(!folder.exists())
			folder.create(true, false, monitor);
		container = container.getFolder(p);
		monitor.worked(1);
	}
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:20,代码来源:NewPackageWizard.java

示例4: createFolderPath

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
/**
 * Creates all non-existing segments of the given path.
 *
 * @param path
 *            The path to create
 * @param parent
 *            The container in which the path should be created in
 * @param monitor
 *            A progress monitor. May be {@code null}
 *
 * @return The folder specified by the path
 */
private IContainer createFolderPath(IPath path, IContainer parent, IProgressMonitor monitor) {
	IContainer activeContainer = parent;

	if (null != monitor) {
		monitor.beginTask("Creating folders", path.segmentCount());
	}

	for (String segment : path.segments()) {
		IFolder folderToCreate = activeContainer.getFolder(new Path(segment));
		try {
			if (!folderToCreate.exists()) {
				createFolder(segment, activeContainer, monitor);
			}
			if (null != monitor) {
				monitor.worked(1);
			}
			activeContainer = folderToCreate;
		} catch (CoreException e) {
			LOGGER.error("Failed to create module folders.", e);
			MessageDialog.open(MessageDialog.ERROR, getShell(),
					FAILED_TO_CREATE_FOLDER_TITLE, String.format(FAILED_TO_CREATE_FOLDER_MESSAGE,
							folderToCreate.getFullPath().toString(), e.getMessage()),
					SWT.NONE);
			break;
		}
	}
	return activeContainer;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:41,代码来源:ModuleSpecifierSelectionDialog.java

示例5: addResource

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
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 ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:38,代码来源:ClientTemplate.java

示例6: createFolder

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
public static void createFolder(String path, IProject project, IProgressMonitor monitor) throws CoreException {
	String[] strings = path.split("/");
	IContainer currentContainer = project;
	for ( String s : strings ) {
		IFolder folder = currentContainer.getFolder( new Path(s) );
		folder.create(true, true, monitor);
		currentContainer = folder;
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:10,代码来源:IFolderUtils.java

示例7: getProposals

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
	IContainer proposalRootFolder;

	if (null == rootFolder) {
		return EMPTY_PROPOSAL;
	}

	if (rootFolder.isEmpty()) {
		proposalRootFolder = ResourcesPlugin.getWorkspace().getRoot();
	} else if (rootFolder.segmentCount() == 1) {
		proposalRootFolder = ResourcesPlugin.getWorkspace().getRoot().getProject(rootFolder.segment(0));
	} else {
		proposalRootFolder = findContainerForPath(rootFolder);
	}

	if (null == proposalRootFolder || !proposalRootFolder.exists()) {
		return EMPTY_PROPOSAL;
	}

	// The field content as path
	IPath contentsPath = new Path(contents);

	// The directory to look for prefix matches
	IPath workingDirectoryPath;

	// If the contents path has a trailing separator...
	if (contentsPath.hasTrailingSeparator()) {
		// Use the full content as working directory path
		workingDirectoryPath = contentsPath;
	} else {
		// Otherwise only use complete segments as working directory
		workingDirectoryPath = contentsPath.removeLastSegments(1);
	}

	IContainer workingDirectory;

	if (workingDirectoryPath.segmentCount() > 0) {
		workingDirectory = proposalRootFolder.getFolder(workingDirectoryPath);
	} else {
		workingDirectory = proposalRootFolder;
	}

	// Return an empty proposal list for non-existing working directories
	if (null == workingDirectory || !workingDirectory.exists()) {
		return EMPTY_PROPOSAL;
	}
	try {
		return Arrays.asList(workingDirectory.members()).stream()
				// Only work with files and folders
				.filter(r -> (r instanceof IFile || r instanceof IFolder))
				// Filter by prefix matching
				.filter(resource -> {
					IPath rootRelativePath = resource.getFullPath().makeRelativeTo(rootFolder);
					return rootRelativePath.toString().startsWith(contentsPath.toString());
				})
				// Transform to a ModuleSpecifierProposal
				.map(resource -> {
					// Create proposal path
					IPath proposalPath = resource.getFullPath()
							.makeRelativeTo(proposalRootFolder.getFullPath());
					// Set the proposal type
					ModuleSpecifierProposal.ModuleProposalType type = resource instanceof IFile
							? ModuleSpecifierProposal.ModuleProposalType.MODULE
							: ModuleSpecifierProposal.ModuleProposalType.FOLDER;
					// Create a new module specifier proposal
					return ModuleSpecifierProposal.createFromPath(proposalPath, type);
				})
				.toArray(IContentProposal[]::new);
	} catch (CoreException e) {
		return EMPTY_PROPOSAL;
	}

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:75,代码来源:ModuleSpecifierContentProposalProviderFactory.java

示例8: createFolder

import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
/**
 * Creates the folder in the given container.
 *
 * @param name
 *            The name of the new folder
 * @param parent
 *            The parent container
 * @param monitor
 *            The progress monitor. May be {@code null}.
 * @throws CoreException
 *             for {@link IFolder#create(boolean, boolean, IProgressMonitor)} exceptions
 * @return The created folder
 */
private IFolder createFolder(String name, IContainer parent, IProgressMonitor monitor) throws CoreException {
	IFolder folder = parent.getFolder(new Path(name));
	folder.create(true, true, monitor);
	return folder;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:ModuleSpecifierSelectionDialog.java


注:本文中的org.eclipse.core.resources.IContainer.getFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。