本文整理匯總了Java中org.eclipse.core.resources.IFolder.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java IFolder.exists方法的具體用法?Java IFolder.exists怎麽用?Java IFolder.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFolder
的用法示例。
在下文中一共展示了IFolder.exists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSubjobInSpecifiedFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* @param subJobXMLPath
* @param parameterFilePath
* @param parameterFile
* @param subJobFile
* @param importFromPath
* @param subjobPath
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
* @throws JAXBException
* @throws ParserConfigurationException
* @throws SAXException
* @throws IOException
* @throws CoreException
* @throws FileNotFoundException
*/
public static Container createSubjobInSpecifiedFolder(IPath subJobXMLPath, IPath parameterFilePath, IFile parameterFile,
IFile subJobFile, IPath importFromPath,String subjobPath) throws InstantiationException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException, JAXBException, ParserConfigurationException,
SAXException, IOException, CoreException, FileNotFoundException {
UiConverterUtil converterUtil = new UiConverterUtil();
Object[] subJobContainerArray=null;
IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(subJobXMLPath);
File file = new File(xmlFile.getFullPath().toString());
if (file.exists()) {
subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(), subJobFile, parameterFile,true);
} else {
IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(parameterFilePath.segment(1));
IFolder iFolder = iProject.getFolder(subjobPath.substring(0, subjobPath.lastIndexOf('/')));
if (!iFolder.exists()) {
iFolder.create(true, true, new NullProgressMonitor());
}
IFile subjobXmlFile = iProject.getFile(subjobPath);
subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(), subJobFile, parameterFile,true);
if (!subjobXmlFile.exists() && subJobContainerArray[1] == null) {
subjobXmlFile.create(new FileInputStream(importFromPath.toString()), true, new NullProgressMonitor());
}
}
return (Container) subJobContainerArray[0];
}
示例2: doFinish
import org.eclipse.core.resources.IFolder; //導入方法依賴的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);
}
}
示例3: getOrCreateServiceClass
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* Gets or creates the debug service class.
*
* @param serviceFolder
* the containing {@link IFolder}
* @param projectName
* the project name
* @param languageName
* the language name
* @param layerName
* the debug layer name
* @param monitor
* the {@link IProgressMonitor}
* @return the debug service class qualified name
* @throws IOException
* @throws CoreException
*/
public static String getOrCreateServiceClass(IFolder serviceFolder,
String projectName, String languageName, String layerName,
IProgressMonitor monitor) throws IOException, CoreException {
final String className = toCamelCase(languageName.replaceAll("\\W", "")) + "DebugServices";
final IFile classFile = serviceFolder.getFile(new Path(className
+ ".java"));
final String packageName = projectName + ".services";
final String res = packageName + "." + className;
if (!classFile.exists()) {
if (!serviceFolder.exists()) {
AddDebugLayerHandler.createFolder(serviceFolder,
monitor);
}
createServiceClass(classFile, packageName, className, languageName,
layerName, monitor);
} else {
addStringCoupleIfNeeded(classFile, languageName, layerName, monitor);
}
return res;
}
示例4: processFile
import org.eclipse.core.resources.IFolder; //導入方法依賴的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 ();
}
}
示例5: createFile
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* Create a file in a folder with the specified name and content
*
* @param projectname
* @param destFolder
* @param filename
* @param content
* @throws CoreException
*/
public static IFile createFile(String projectname, String destFolder, String pkg, String filename, String content)
throws CoreException {
IProject project = getProject(projectname);
IFolder folder = project.getFolder(new Path(destFolder));
if (!folder.exists())
folder.create(true, true, null);
IFolder container = folder;
if (pkg != null) {
StringTokenizer st = new StringTokenizer(pkg, "/");
while (st.hasMoreTokens()) {
String dir = st.nextToken();
IFolder f = container.getFolder(new Path(dir));
if (!f.exists()) {
f.create(true, true, null);
}
container = f;
}
}
IFile newFile = container.getFile(new Path(filename));
newFile.create(new ByteArrayInputStream(content.getBytes()), true, null);
return newFile;
}
示例6: createFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/***/
protected IFolder createFolder(IFolder superFolder, String path) throws CoreException {
IFolder folder = superFolder.getFolder(path);
if (!folder.exists()) {
createParentFolder(folder);
folder.create(true, true, null);
}
return folder;
}
示例7: createProjectScriptFile
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private IEditorInput createProjectScriptFile(String content, String filename) throws CoreException, IOException {
Log.log(Log.LOG_INFO, "Creating file " + filename); //$NON-NLS-1$
IProject iProject = proj.getProject();
IFolder folder = iProject.getFolder(PROJ_PATH.MIGRATION_DIR);
if (!folder.exists()){
folder.create(IResource.NONE, true, null);
}
IFile file = folder.getFile(filename + ".sql"); //$NON-NLS-1$
InputStream source = new ByteArrayInputStream(content.getBytes(proj.getProjectCharset()));
file.create(source, IResource.NONE, null);
return new FileEditorInput(iProject.getFile(file.getProjectRelativePath()));
}
示例8: createParentFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/***/
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);
}
}
}
示例9: createFolderPath
import org.eclipse.core.resources.IFolder; //導入方法依賴的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;
}
示例10: fullBuild
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
protected void fullBuild(IProgressMonitor monitor) throws CoreException{
Visuflow.getDefault().getLogger().info("Build Start");
String targetFolder = "sootOutput";
IJavaProject project = JavaCore.create(getProject());
IResourceDelta delta = getDelta(project.getProject());
if (delta == null || !delta.getAffectedChildren()[0].getProjectRelativePath().toString().equals(targetFolder)) {
classpath = getSootCP(project);
String location = GlobalSettings.get("Target_Path");
IFolder folder = project.getProject().getFolder(targetFolder);
// at this point, no resources have been created
if (!folder.exists()) {
// Changed to force because of bug id vis-119
folder.create(IResource.FORCE, true, monitor);
} else {
for (IResource resource : folder.members()) {
resource.delete(IResource.FORCE, monitor);
}
}
classpath = location + classpath;
String[] sootString = new String[] { "-cp", classpath, "-exclude", "javax", "-allow-phantom-refs", "-no-bodies-for-excluded", "-process-dir",
location, "-src-prec", "only-class", "-w", "-output-format", "J", "-keep-line-number", "-output-dir",
folder.getLocation().toOSString()/* , "tag.ln","on" */ };
ICFGStructure icfg = new ICFGStructure();
JimpleModelAnalysis analysis = new JimpleModelAnalysis();
analysis.setSootString(sootString);
List<VFClass> jimpleClasses = new ArrayList<>();
try {
analysis.createICFG(icfg, jimpleClasses);
fillDataModel(icfg, jimpleClasses);
} catch(Exception e) {
logger.error("Couldn't execute analysis", e);
}
folder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
示例11: createFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* Create recursively folders in the project.
* Do nothing if folder already exists.
* @param project
* @param path
* @param monitor
* @return
* @throws CoreException
*/
public static IFolder createFolder(IProject project, IPath path, IProgressMonitor monitor) throws CoreException {
IFolder folder = project.getFolder(path);
if (!folder.exists()) {
if (path.segmentCount() > 1) {
IPath currentFolderPath = new Path("");
for (int i=0; i<path.segmentCount()-1; i++) {
currentFolderPath = currentFolderPath.append(path.segment(i));
createFolder(project, currentFolderPath, monitor);
}
}
folder.create(true, true, monitor);
}
return folder;
}
示例12: addResource
import org.eclipse.core.resources.IFolder; //導入方法依賴的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 ();
}
示例13: createTemprarySourceFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private IPath createTemprarySourceFolder(){
IPath tempSrcFolder=new Path(PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER);
IFolder folder=BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject().getFolder(tempSrcFolder);
try {
if(!folder.exists()){
folder.create(true, true,null);
}
} catch (CoreException e) {
LOGGER.error("CoreException occurred while creating temporary source folder",e);
return null;
}
LOGGER.debug("Created temporary build path at "+PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER);
return folder.getFullPath();
}
示例14: getPropertyFilePath
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private static String getPropertyFilePath(IJavaProject project) {
LOGGER.debug("Adding UserFunctions.propertis file URL to build-path");
IFolder settingFolder=project.getProject().getFolder(PathConstant.PROJECT_RESOURCES_FOLDER);
if(settingFolder.exists()){
IFile file=settingFolder.getFile(PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
if(file.exists()){
return file.getLocation().toString();
}
}
return Constants.EMPTY_STRING;
}
示例15: createProject
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
public static IJavaProject createProject(String name) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(name);
if (!project.exists()) {
project.create(new NullProgressMonitor());
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
if (!project.isOpen()) {
project.open(new NullProgressMonitor());
}
IFolder binFolder = project.getFolder("bin");
if (!binFolder.exists()) {
createFolder(binFolder, false, true, new NullProgressMonitor());
}
IPath outputLocation = binFolder.getFullPath();
addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());
IJavaProject jproject = JavaCore.create(project);
jproject.setOutputLocation(outputLocation, new NullProgressMonitor());
IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();
jproject.setRawClasspath(entries, new NullProgressMonitor());
return jproject;
}