本文整理匯總了Java中org.eclipse.core.resources.IProject.getFile方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.getFile方法的具體用法?Java IProject.getFile怎麽用?Java IProject.getFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IProject
的用法示例。
在下文中一共展示了IProject.getFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copyBuildFile
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void copyBuildFile(String source, IProject project) throws CoreException {
File sourceFileLocation = new File(source);
File[] listFiles = sourceFileLocation.listFiles();
if(listFiles != null){
for(File sourceFile : listFiles){
IFile destinationFile = project.getFile(sourceFile.getName());
try(InputStream fileInputStream = new FileInputStream(sourceFile)) {
if(!destinationFile.exists()){ //used while importing a project
destinationFile.create(fileInputStream, true, null);
}
} catch (IOException | CoreException exception) {
logger.debug("Copy build file operation failed");
throw new CoreException(new MultiStatus(Activator.PLUGIN_ID, 100, "Copy build file operation failed", exception));
}
}
}
}
示例2: 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];
}
示例3: openXMLTransactionStepEditor
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void openXMLTransactionStepEditor(IProject project)
{
TransactionStep transactionStep = (TransactionStep)this.getObject();
IFile file = project.getFile("_private/"+transactionStep.getName()+".xml");
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
if (activePage != null) {
try {
activePage.openEditor(new XMLTransactionStepEditorInput(file,transactionStep),
"com.twinsoft.convertigo.eclipse.editors.xml.XMLTransactionStepEditor");
}
catch(PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the step editor '" + transactionStep.getName() + "'");
}
}
}
示例4: openXMLSequenceEditor
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void openXMLSequenceEditor(IProject project) {
Sequence sequence = getObject();
IFile file = project.getFile("_private/"+sequence.getName()+".xml");
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
if (activePage != null) {
try {
activePage.openEditor(new XMLSequenceEditorInput(file,sequence),
"com.twinsoft.convertigo.eclipse.editors.xml.XMLSequenceEditor");
}
catch(PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the step editor '" + sequence.getName() + "'");
}
}
}
示例5: createManifest
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void createManifest(String projectName, String string) throws CoreException, UnsupportedEncodingException {
IProject project = workspace.getProject(projectName);
IFile manifestFile = project.getFile(IN4JSProject.N4MF_MANIFEST);
@SuppressWarnings("resource")
StringInputStream content = new StringInputStream(string, Charsets.UTF_8.name());
manifestFile.create(content, false, null);
manifestFile.setCharset(Charsets.UTF_8.name(), null);
IFolder src = project.getFolder("src");
src.create(false, true, null);
IFolder sub = src.getFolder("sub");
sub.create(false, true, null);
IFolder leaf = sub.getFolder("leaf");
leaf.create(false, true, null);
src.getFile("A.js").create(new ByteArrayInputStream(new byte[0]), false, null);
src.getFile("B.js").create(new ByteArrayInputStream(new byte[0]), false, null);
sub.getFile("B.js").create(new ByteArrayInputStream(new byte[0]), false, null);
sub.getFile("C.js").create(new ByteArrayInputStream(new byte[0]), false, null);
leaf.getFile("D.js").create(new ByteArrayInputStream(new byte[0]), false, null);
}
示例6: testListBase
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@SuppressWarnings("javadoc")
@Test
public void testListBase() throws Exception {
IProject project = ProjectUtils.importProject(new File("probands"), "ListBase");
IResourcesSetupUtil.waitForBuild();
IFile underscore_js = project.getFile("src/underscore/underscore.n4js");
assertTrue(underscore_js.exists());
assertMarkers(underscore_js + " should have no errors, one unused variable warning", underscore_js, 1);
IFile listbase_js = project.getFile("src/n4/lang/ListBase.n4js");
assertTrue(listbase_js.exists());
final Collection<IMarker> allMarkers = newHashSet(listbase_js.findMarkers(MarkerTypes.ANY_VALIDATION, true,
IResource.DEPTH_INFINITE));
assertTrue(format(EXPECTED_NUMBER_OF_ISSUE_TEMPLATE, allMarkers.size()),
NUMBER_OF_EXPECTED_ISSUES == allMarkers.size());
long unexpectedMarkerCount = allMarkers.stream()
.filter(EXPECTED_VALIDATION_PREDICATE.negate())
.count();
assertTrue("Unexpected validation issues were found. " + toString(allMarkers), unexpectedMarkerCount == 0);
}
示例7: launchEditor
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void launchEditor(String editorType) {
// Retrieve the workspace project
try {
String projectName = ((DatabaseObject) parent.getObject()).getProject().getName();
// Refresh project resource
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
Sheet sheet = (Sheet) parent.getObject();
//String parentStyleSheet = sheet.getUrl();
// Gets the xsl file to be edited
IFile file = project.getFile(new Path(xslPath));
// Launch the XslStyleSheet Editor
PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.openEditor(new XslFileEditorInput(file, projectName, sheet),
"com.twinsoft.convertigo.eclipse.editors.xsl.XslRuleEditor");
} catch (Exception pei) {
ConvertigoPlugin.logException(pei, "Unexpceted exception");
}
}
示例8: openXMLTransactionEditor
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void openXMLTransactionEditor(IProject project) {
Transaction transaction = (Transaction)this.getObject();
IFile file = project.getFile("_private/"+transaction.getName()+".xml");
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
if (activePage != null) {
try {
activePage.openEditor(new XMLTransactionEditorInput(file,transaction),
"com.twinsoft.convertigo.eclipse.editors.xml.XMLTransactionEditor");
} catch(PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the transaction editor '" + transaction.getName() + "'");
}
}
}
示例9: openJscriptTransactionEditor
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void openJscriptTransactionEditor(IProject project) {
Transaction transaction = (Transaction)this.getObject();
String tempFileName = "_private/"+project.getName()+
"__"+transaction.getConnector().getName()+
"__"+transaction.getName();
IFile file = project.getFile(tempFileName);
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
if (activePage != null) {
try {
activePage.openEditor(new JscriptTransactionEditorInput(file,transaction),
"com.twinsoft.convertigo.eclipse.editors.jscript.JscriptTransactionEditor");
} catch(PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the transaction editor '" + transaction.getName() + "'");
}
}
}
示例10: openTextEditor
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public void openTextEditor(IProject project) {
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject)this.parent.parent;
IFile file = project.getFile("Traces/"+ connectorTreeObject.getName() + "/" + this.getName());
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
if (activePage != null) {
try {
activePage.openEditor(new TraceFileEditorInput(connectorTreeObject.getObject(), file),"org.eclipse.ui.DefaultTextEditor");
} catch(PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the text editor.");
}
}
}
示例11: addEntryInProperty
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Add a new entry for a property of build.properties file
* This adds the entry in the comma separated format for the property.
* If the entry is already present, the method will have no effect.
* @throws IOException
* @param project
* @param propertyName
* @param newEntryValue new value that must be added in the source property of the given jar
* @param monitor
* @throws CoreException
* @throws IOException
*/
public static void addEntryInProperty(IProject project, String propertyName, String newEntryValue, IProgressMonitor monitor) throws CoreException, IOException {
Properties properties = new Properties();
IFile file = project.getFile("build.properties");
if(file.exists()) {
properties.load(file.getContents(true));
String commaSeparatedPropvalues = properties.getProperty(propertyName);
if(commaSeparatedPropvalues != null){
// check if it is already there
List<String> propValues = Arrays.asList(commaSeparatedPropvalues.split(","));
for (String srcEntry : propValues) {
if(srcEntry.trim().replaceAll("\\\\", "").equals(newEntryValue)){
// nothing to do, already there!
return;
}
}
// not found, so add it to the end
String newcommaSeparatedPropvalues = commaSeparatedPropvalues + ","+newEntryValue;
properties.setProperty(propertyName, newcommaSeparatedPropvalues);
} else {
properties.setProperty(propertyName, newEntryValue);
}
} else {
properties.setProperty(propertyName, newEntryValue);
}
StringWriter writer = new StringWriter();
properties.store(writer, "");
IFileUtils.writeInFile(file, writer.toString(), monitor);
}
示例12: testIgnoredModuleWithSuperClass
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Runs a test module with one single class that is annotated with {@code @Ignore} and has a super class.
*/
@Test
public void testIgnoredModuleWithSuperClass() {
final IProject project = getProjectByName(PROJECT_NAME);
assertTrue("Project is not accessible.", project.isAccessible());
final IFile module = project.getFile("test/B.n4js");
assertTrue("Module is not accessible.", module.isAccessible());
runTestWaitResult(module);
final String[] expected = EMPTY_ARRAY;
final String[] actual = getConsoleContentLines();
assertArrayEquals(expected, actual);
}
示例13: addResource
import org.eclipse.core.resources.IProject; //導入方法依賴的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 ();
}
示例14: createExample
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
protected void createExample(IProject project) {
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
try (InputStream stream = FileLocator.openStream(bundle, new Path("examples/greeter.sol"), false)) {
IFile file = project.getFile("greeter.sol");
file.create(stream, true, null);
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: editPageFunction
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void editPageFunction(final UIComponent uic, final String functionMarker, final String propertyName) {
final PageComponent page = uic.getPage();
try {
// Refresh project resources for editor
String projectName = page.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor and Reopen it after file has been rewritten
String relativePath = page.getProject().getMobileBuilder().getFunctionTempTsRelativePath(page);
IFile file = project.getFile(relativePath);
closeComponentFileEditor(file);
page.getProject().getMobileBuilder().writeFunctionTempTsFile(page, functionMarker);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, uic);
if (input != null) {
IEditorDescriptor desc = PlatformUI
.getWorkbench()
.getEditorRegistry()
.getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor)source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
String marker = MobileBuilder.getMarker(doc.get(), functionMarker);
String beginMarker = "/*Begin_c8o_" + functionMarker + "*/";
String endMarker = "/*End_c8o_" + functionMarker + "*/";
String content = marker.replace(beginMarker+ System.lineSeparator(), "")
.replace("\t\t"+endMarker, "") // for validator
.replace("\t"+endMarker, ""); // for action
FormatedContent formated = new FormatedContent(content);
MobileUIComponentTreeObject.this.setPropertyValue(propertyName, formated);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to edit function for page '" + page.getName() + "'!");
}
}