本文整理匯總了Java中org.eclipse.core.resources.IProject.getFolder方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.getFolder方法的具體用法?Java IProject.getFolder怎麽用?Java IProject.getFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IProject
的用法示例。
在下文中一共展示了IProject.getFolder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deleteCorrospondingXmlAndPropertyFileifUserDeleteJobFile
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private boolean deleteCorrospondingXmlAndPropertyFileifUserDeleteJobFile(IProject iProject) {
if (modifiedResource.getProjectRelativePath()!=null && StringUtils.equalsIgnoreCase(modifiedResource.getProjectRelativePath().segment(0),
CustomMessages.ProjectSupport_JOBS)) {
IFile propertyFileName = null;
IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS);
IFolder propertiesFolder = iProject.getFolder(Messages.PARAM);
if (jobsFolder != null) {
xmlIFile=jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2).removeFileExtension().addFileExtension(Constants.XML_EXTENSION_FOR_IPATH));
}
if (propertiesFolder != null) {
propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension()
.addFileExtension(Constants.PROPERTIES).toFile().getName());
}
String message = getErrorMessageIfUserDeleteJobRelatedFiles(propertyFileName, xmlIFile);
showErrorMessage(xmlIFile, propertyFileName, Messages.bind(message, modifiedResource.getName()));
} else {
flag = true;
}
return flag;
}
示例2: doSaveAs
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
public void doSaveAs() {
String jobId = getActiveProject() + "." + getJobName();
DataViewerUtility.INSTANCE.closeDataViewerWindows(JobManager.INSTANCE.getPreviouslyExecutedJobs().get(jobId));
deleteDebugFiles(jobId);
Map<String, String> currentParameterMap = getCurrentParameterMap();
IFile file=opeSaveAsDialog();
saveJob(file,true);
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(getActiveProject());
IFolder paramFolder = project.getFolder(Messages.PARAM);
IFile filename=paramFolder.getFile(oldFileName.replace(Messages.JOBEXTENSION,Messages.PROPERTIES_EXTENSION));
copyParameterFile(currentParameterMap,filename);
}
示例3: createChange
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
copyToPath=getArguments().getDestination().toString();
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(copyToPath.split("/")[1]);
IFolder jobFolder = project.getFolder(copyToPath.substring(copyToPath.indexOf('/', 2)));
previousJobFiles=new ArrayList<>();
for (IResource iResource : jobFolder.members()) {
if (!(iResource instanceof IFolder)) {
IFile iFile = (IFile) iResource;
if (iFile.getFileExtension().equalsIgnoreCase(Messages.JOB_EXT)) {
previousJobFiles.add(iFile);
}
}
}
copiedFileList.add(modifiedResource);
return null;
}
示例4: createContainerControls
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
protected void createContainerControls(Composite parent, int nColumns) {
super.createContainerControls(parent, nColumns);
Text text = (Text) parent.getChildren()[1];
text.setEditable(false);
IEditorInput editorInput = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.getActiveEditor().getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
IProject project = fileEditorInput.getFile().getProject();
if (project != null) {
IFolder srcFolder = project.getFolder("src/main/java");
if (srcFolder != null && srcFolder.exists()) {
text.setText(project.getName() + "/" + srcFolder.getProjectRelativePath().toString());
}
}
Button button = (Button) parent.getChildren()[2];
button.setEnabled(false);
}
}
示例5: getFile
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* @param projectname
* @param folder
* @param filename
* @return whether the file exists in the specified project & folder
* @throws CoreException
*/
public static File getFile(String projectname, String folder, String pkg, String filename) throws CoreException {
IProject project = getProject(projectname);
IFolder destFolder = project.getFolder(new Path(folder));
IFolder container = destFolder;
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 file = container.getFile(new Path(filename));
return file.getRawLocation().makeAbsolute().toFile();
}
示例6: createSchema
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
static IFolder createSchema(String name, boolean open, IProject project) throws CoreException {
IFolder projectFolder = project.getFolder(DbObjType.SCHEMA.name());
if (!projectFolder.exists()) {
projectFolder.create(false, true, null);
}
IFolder schemaFolder = projectFolder.getFolder(name);
if (!schemaFolder.exists()) {
schemaFolder.create(false, true, null);
}
IFile file = projectFolder.getFile(name + POSTFIX);
if (!file.exists()) {
StringBuilder sb = new StringBuilder();
sb.append(MessageFormat.format(PATTERN, DbObjType.SCHEMA, name));
sb.append(MessageFormat.format(OWNER_TO, DbObjType.SCHEMA, name));
file.create(new ByteArrayInputStream(sb.toString().getBytes()), false, null);
}
if (open) {
openFileInEditor(file);
}
return schemaFolder;
}
示例7: createSubjobInSpecifiedFolder
import org.eclipse.core.resources.IProject; //導入方法依賴的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];
}
示例8: createFolder
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/***/
protected IFolder createFolder(IProject project, String path) throws CoreException {
IFolder folder = project.getFolder(path);
if (!folder.exists()) {
createParentFolder(folder);
folder.create(true, true, null);
}
return folder;
}
示例9: createProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* This method creates a new java project based on the user inputs, captured in WizardInput object.
* The new project is created in the current workspace.
* @param wizardInput
* @return IJavaProject
* @throws CoreException
* @throws IOException
**/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(wizardInput.getProjectName());
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
IFolder binFolder = project.getFolder("bin");
binFolder.create(false, true, null);
javaProject.setOutputLocation(binFolder.getFullPath(), null);
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation element : locations) {
entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
}
InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
IFile jarFile = project.getFile("soot-trunk.jar");
jarFile.create(is, false, null);
IPath path = jarFile.getFullPath();
entries.add(JavaCore.newLibraryEntry(path, null, null));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
IFolder sourceFolder = project.getFolder("src");
sourceFolder.create(false, true, null);
IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
javaProject.setRawClasspath(newEntries, null);
String filepath = sourceFolder.getLocation().toOSString();
File file = new File(filepath);
wizardInput.setFile(file);
try {
CodeGenerator.generateSource(wizardInput);
} catch (JClassAlreadyExistsException e) {
e.printStackTrace();
}
sourceFolder.refreshLocal(1, null);
javaProject.open(null);
return javaProject;
}
示例10: updateProposalContext
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* 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);
}
}
}
示例11: createProjectN4JSSourceContainer
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@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);
}
示例12: addToProjectStructure
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Create a folder structure as specified in the parameters
* @param newProject
* @param paths contains the names of the folder that need to be created.
* @throws CoreException
*/
private void addToProjectStructure(IProject newProject, String[] paths) throws CoreException {
for (String path : paths) {
IFolder etcFolders = newProject.getFolder(path);
createFolder(etcFolders);
}
}
示例13: createProject
import org.eclipse.core.resources.IProject; //導入方法依賴的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;
}
示例14: addFolderToClassPath
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static IPackageFragmentRoot addFolderToClassPath(IJavaProject jproject, String containerName)
throws CoreException {
IProject project = jproject.getProject();
IFolder folder = project.getFolder(containerName);
if (!folder.exists()) {
createFolder(folder, false, true, new NullProgressMonitor());
}
IClasspathEntry cpe = JavaCore.newLibraryEntry(folder.getFullPath(), null, null);
addToClasspath(jproject, cpe);
return jproject.getPackageFragmentRoot(folder);
}
示例15: createExtension
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
static void createExtension(String name, IProject project) throws CoreException {
IFolder folder = project.getFolder(DbObjType.EXTENSION.name());
if (!folder.exists()) {
folder.create(false, true, null);
}
IFile extFile = folder.getFile(name + POSTFIX);
if (!extFile.exists()) {
String code = MessageFormat.format(PATTERN, DbObjType.EXTENSION, name);
extFile.create(new ByteArrayInputStream(code.getBytes()), false, null);
}
openFileInEditor(extFile);
}