Java Code Examples for org.eclipse.core.resources.IFile

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  23 
vote

/** 
 * This also changes the editor's input. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSaveAs(){
  SaveAsDialog saveAsDialog=new SaveAsDialog(getSite().getShell());
  saveAsDialog.open();
  IPath path=saveAsDialog.getResult();
  if (path != null) {
    IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    if (file != null) {
      doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(),true),new FileEditorInput(file));
    }
  }
}
 

Example 2

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial/src/org/eclipse/acceleo/tutorial/wizard/.

Source file: EclipseConWizard.java

  22 
vote

public static void writeFile(File file,IFolder folder,IProgressMonitor monitor){
  String emtlContent=getFileContent(file);
  IFile newFile=folder.getFile(file.getName());
  if (!newFile.exists()) {
    InputStream contents=new ByteArrayInputStream(emtlContent.getBytes());
    try {
      newFile.create(contents,true,monitor);
    }
 catch (    CoreException e) {
      e.printStackTrace();
    }
  }
}
 

Example 3

From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/builder/.

Source file: BELCompileBuilder.java

  22 
vote

void checkXML(IResource resource){
  if (resource instanceof IFile && resource.getName().endsWith(".xml")) {
    IFile file=(IFile)resource;
    deleteMarkers(file);
    XMLErrorHandler reporter=new XMLErrorHandler(file);
    try {
      getParser().parse(file.getContents(),reporter);
    }
 catch (    Exception e1) {
    }
  }
}
 

Example 4

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/wizards/export/.

Source file: TraviandoExportWizard.java

  22 
vote

public BioNessieTraceLog createBioNessieTraceLogger(int index,IPath bioNessieFilePath,SimulationTraceJob traceJob){
  IPath numberPath=bioNessieFilePath.removeFileExtension();
  if (index > 0) {
    numberPath=numberPath.addFileExtension(Integer.toString(index));
  }
  numberPath=numberPath.addFileExtension("bn");
  IFile file=ResourcesPlugin.getWorkspace().getRoot().getFile(numberPath);
  String filePath=file.getLocation().toOSString();
  FileStringConsumer fsc=new FileStringConsumer(filePath);
  BioNessieTraceLog travLog=new BioNessieTraceLog(fsc,model.getSBAModel());
  travLog.setCompleteConsumer(true);
  traceJob.addOutputFile(file);
  return travLog;
}
 

Example 5

From project bioclipse.opentox, under directory /plugins/net.bioclipse.opentox/src/net/bioclipse/opentox/business/.

Source file: OpentoxManager.java

  22 
vote

public IFile downloadDataSetAsMDLSDfile(String service,String dataSet,IFile file,IProgressMonitor monitor) throws BioclipseException {
  if (monitor == null)   monitor=new NullProgressMonitor();
  monitor.beginTask("Downloading data set...",1);
  Map<String,String> extraHeaders=null;
  if (getToken() != null) {
    extraHeaders=new HashMap<String,String>();
    extraHeaders.put("subjectid",getToken());
  }
  IFile result=bioclipse.downloadAsFile(dataSet,"chemical/x-mdl-sdfile",file,extraHeaders,monitor);
  monitor.done();
  return result;
}
 

Example 6

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/editor/.

Source file: SenecaJobEditor.java

  22 
vote

private void saveSDFile(List<IMolecule> mols,String jobTitle) throws BioclipseException, InvocationTargetException {
  IStructuredSelection virtualselection=new StructuredSelection(net.bioclipse.core.Activator.getVirtualProject());
  String filename=WizardHelper.findUnusedFileName(virtualselection,"Seneca_" + jobTitle,".sdf");
  final IFile sdfile=net.bioclipse.core.Activator.getVirtualProject().getFile(filename);
  net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager().saveSDFile(sdfile,mols,new BioclipseUIJob<Void>(){
    @Override public void runInUI(){
      net.bioclipse.ui.business.Activator.getDefault().getUIManager().open(sdfile);
    }
  }
);
}
 

Example 7

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.specmol.test/src/net/bioclipse/specmol/business/test/.

Source file: AbstractSpecmolManagerPluginTest.java

  22 
vote

@Test public void testSaveSpecmol_IJumboSpecmol_IFile() throws URISyntaxException, IOException, BioclipseException, CoreException {
  URI uri=getClass().getResource("/testFiles/Maaranolide_G.xml").toURI();
  URL url=FileLocator.toFileURL(uri.toURL());
  String path=url.getFile();
  ISpecmol spectrum=specmolmanager.loadSpecmol(path);
  IFile target=new MockIFile();
  specmolmanager.saveSpecmol((IJumboSpecmol)spectrum,target);
  byte[] bytes=new byte[3];
  target.getContents().read(bytes);
  Assert.assertEquals(60,bytes[0]);
  Assert.assertEquals(63,bytes[1]);
  Assert.assertEquals(120,bytes[2]);
}
 

Example 8

From project bioclipse.vscreen, under directory /net.bioclipse.vscreen.tests/src/net/bioclipse/vscreen/tests/.

Source file: AbstractVScreenManagerPluginTest.java

  22 
vote

@Before public void initialize() throws IOException, CoreException, BioclipseException, URISyntaxException {
  sdb=Activator.getDefault().getStructuredbManager();
  if (sdb.allDatabaseNames().contains(TEST_DB_NAME)) {
    sdb.deleteDatabase(TEST_DB_NAME,new NullProgressMonitor());
  }
  sdb.createDatabase(TEST_DB_NAME);
  IFile file=null;
  URI uri=getClass().getResource(TEST_FILE).toURI();
  URL url=FileLocator.toFileURL(uri.toURL());
  String path=url.getFile();
  file=FileUtil.createLinkedFile(path);
  sdb.addMoleculesFromSDF(TEST_DB_NAME,file);
}
 

Example 9

From project bndtools, under directory /bndtools.core/src/bndtools/builder/.

Source file: NewBuilder.java

  22 
vote

private void clearBuildMarkers() throws CoreException {
  IFile bndFile=getProject().getFile(Project.BNDFILE);
  if (bndFile.exists()) {
    bndFile.deleteMarkers(MARKER_BND_PROBLEM,true,IResource.DEPTH_INFINITE);
  }
}
 

Example 10

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/launch/.

Source file: BPELLaunchMainTab.java

  22 
vote

public void setDefaults(ILaunchConfigurationWorkingCopy configuration){
  IFile selectedFile=getContext();
  if (selectedFile != null) {
    initializeProject(selectedFile,configuration);
  }
 else {
    configuration.setAttribute(LaunchConstants.ATTR_PROJECT_NAME,LaunchConstants.EMPTY_STRING);
  }
  initializeSuiteAndName(selectedFile,configuration);
}
 

Example 11

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/.

Source file: BPMN2DiagramCreator.java

  22 
vote

/** 
 * Return the temporary file to be used as editor input. Conceptually, this is the "diagramFile" mentioned here which is just a placeholder for use by Graphiti as the DiagramEditorInput file.
 * @param fullPath - path of the actual BPMN2 model file
 * @param folder - folder containing the model file
 * @return an IFile for the temporary file. If the file exists, it is first deleted.
 */
public static IFile getTempFile(IPath fullPath,IFolder folder){
  IPath path=fullPath.removeFileExtension().addFileExtension(TEMPFILE_EXTENSION);
  IFile tempFile=folder.getFile(path.lastSegment());
  if (tempFile.exists()) {
    try {
      tempFile.delete(true,null);
    }
 catch (    CoreException e) {
      Activator.showErrorWithLogging(e);
    }
  }
  return tempFile;
}
 

Example 12

From project bundlemaker, under directory /main/org.bundlemaker.core.store.db4o/src/org/bundlemaker/core/store/db4o/internal/.

Source file: PersistentDependencyStoreFactoryComponent.java

  22 
vote

/** 
 * @see org.bundlemaker.core.internal.store.IPersistentDependencyStoreFactory#resetPersistentDependencyStore(org.bundlemaker.core.IBundleMakerProject)
 */
public void resetPersistentDependencyStore(IBundleMakerProject project) throws CoreException {
  if (_cache.containsKey(project)) {
    PersistentDependencyStoreImpl infoStore=_cache.get(project);
    if (infoStore.isInitialized()) {
      infoStore.dispose();
    }
  }
  IFile file=project.getProject().getFile(".bundlemaker/db4o.store");
  file.delete(true,null);
  if (_cache.containsKey(project)) {
    PersistentDependencyStoreImpl dependencyStore=_cache.get(project);
    dependencyStore.init();
  }
}
 

Example 13

From project ccw, under directory /ccw.core/src/java/ccw/.

Source file: ClojureProject.java

  22 
vote

public void checkClasspath(){
  IFile classpath=project.getProject().getFile(".classpath");
  if (!classpath.exists())   return;
  if (classpathUpdate == IResource.NULL_STAMP) {
    classpathUpdate=classpath.getModificationStamp();
    return;
  }
  if (classpathUpdate == classpath.getModificationStamp())   return;
  classpathUpdate=classpath.getModificationStamp();
}
 

Example 14

From project CBCJVM, under directory /eclipse/src/cbclipse/builder/.

Source file: CBCNature.java

  21 
vote

public void configure() throws CoreException {
  IProjectDescription desc=project.getDescription();
  ICommand[] commands=desc.getBuildSpec();
  for (int i=0; i < commands.length; ++i) {
    if (commands[i].getBuilderName().equals(CBCBuilder.BUILDER_ID)) {
      return;
    }
  }
  ICommand[] newCommands=new ICommand[commands.length + 1];
  System.arraycopy(commands,0,newCommands,0,commands.length);
  ICommand command=desc.newCommand();
  command.setBuilderName(CBCBuilder.BUILDER_ID);
  newCommands[newCommands.length - 1]=command;
  desc.setBuildSpec(newCommands);
  project.setDescription(desc,null);
  IJavaProject javaProject=JavaCore.create(project);
  Set<IClasspathEntry> entries=new HashSet<IClasspathEntry>();
  entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
  String osPath=Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.P_PATH);
  IPath path=Path.fromOSString(osPath);
  LibraryLocation location=new LibraryLocation(path,Path.EMPTY,Path.EMPTY);
  entries.add(JavaCore.newLibraryEntry(location.getSystemLibraryPath(),null,null));
  javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]),new NullProgressMonitor());
  IFile commCBC=project.getFile("comm.cbc");
  commCBC.create(new ByteArrayInputStream(new byte[]{}),true,new NullProgressMonitor());
}
 

Example 15

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/discovery/.

Source file: NDKDiscoveredPathInfo.java

  19 
vote

private void load(){
  try {
    File infoFile=getInfoFile();
    if (!infoFile.exists())     return;
    long timestamp=IFile.NULL_STAMP;
    List<IPath> includes=new ArrayList<IPath>();
    Map<String,String> defines=new HashMap<String,String>();
    BufferedReader reader=new BufferedReader(new FileReader(infoFile));
    for (String line=reader.readLine(); line != null; line=reader.readLine()) {
switch (line.charAt(0)) {
case 't':
        timestamp=Long.valueOf(line.substring(2));
      break;
case 'i':
    includes.add(Path.fromPortableString(line.substring(2)));
  break;
case 'd':
int n=line.indexOf(',',2);
if (n == -1) defines.put(line.substring(2),"");
 else defines.put(line.substring(2,n),line.substring(n + 1));
break;
}
}
reader.close();
lastUpdate=timestamp;
includePaths=includes.toArray(new IPath[includes.size()]);
symbols=defines;
}
 catch (IOException e) {
Activator.log(e);
}
}
 

Example 16

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/explorer/s3/dnd/.

Source file: DownloadDropAssistant.java

  19 
vote

protected IStatus doDrop(Object aTarget,IStructuredSelection s3ObjectSelection){
  if (!(aTarget instanceof IResource)) {
    return Status.CANCEL_STATUS;
  }
  IResource resource=(IResource)aTarget;
  if (resource instanceof IFile) {
    resource=resource.getParent();
  }
  final IResource dropFolder=resource;
  final S3ObjectSummary s3object=(S3ObjectSummary)s3ObjectSelection.getFirstElement();
  final File f=dropFolder.getLocation().toFile();
  if (!f.exists())   return Status.CANCEL_STATUS;
  String fileName=getOutputFileName(s3object,f);
  if (fileName == null || fileName.length() == 0) {
    return Status.CANCEL_STATUS;
  }
  final File outputFile=new File(fileName);
  new DownloadObjectJob("Downloading " + s3object.getKey(),s3object,dropFolder,outputFile).schedule();
  return Status.OK_STATUS;
}