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

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 bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/navigator/.

Source file: BaseDocumentsFolder.java

  24 
vote

@Override public boolean equals(Object o){
  if (o == this)   return true;
  if (o instanceof IFolder) {
    IFolder other=(IFolder)o;
    return folder.equals(other);
  }
  return false;
}
 

Example 2

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

Source file: FileUtils.java

  24 
vote

public static File toFile(IWorkspaceRoot root,IPath path){
  IFile wsfile;
  IFolder wsfolder;
  if ((wsfile=root.getFile(path)).exists()) {
    IPath location=wsfile.getLocation();
    if (location != null)     return location.toFile();
  }
  if ((wsfolder=root.getFolder(path)).exists()) {
    IPath location=wsfolder.getLocation();
    if (location != null)     return location.toFile();
  }
  return path.toFile();
}
 

Example 3

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

Source file: BPMN2Editor.java

  22 
vote

/** 
 * Beware, creates a new input and changes this editor!
 */
private IEditorInput createNewDiagramEditorInput() throws CoreException {
  IPath fullPath=modelFile.getFullPath();
  modelUri=URI.createPlatformResourceURI(fullPath.toString(),true);
  IFolder folder=BPMN2DiagramCreator.getTempFolder(fullPath);
  diagramFile=BPMN2DiagramCreator.getTempFile(fullPath,folder);
  BPMN2DiagramCreator creator=new BPMN2DiagramCreator();
  creator.setDiagramFile(diagramFile);
  IEditorInput input=creator.createDiagram(false);
  diagramUri=creator.getUri();
  return input;
}
 

Example 4

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/core/vfs/.

Source file: IFolderVirtualFile.java

  22 
vote

@Override public List<VirtualFile> getChildren(){
  List<VirtualFile> children=new ArrayList<VirtualFile>();
  IFolder folder=(IFolder)resource;
  try {
    for (    IResource childResource : folder.members()) {
      children.add(ResourceVirtualFile.createResourceVirtualFile(childResource));
    }
  }
 catch (  CoreException e) {
    e.printStackTrace();
  }
  return children;
}
 

Example 5

From project dawn-isenciaui, under directory /com.teaminabox.eclipse.wiki/test/com/teaminabox/eclipse/wiki/.

Source file: WikiTest.java

  22 
vote

private void createFolders(IPath path) throws CoreException {
  for (int i=path.segmentCount() - 1; i >= 0; i--) {
    IFolder folder=project.getFolder(path.removeLastSegments(i));
    if (!folder.exists()) {
      folder.create(true,true,null);
    }
  }
}
 

Example 6

From project dawn-ui, under directory /org.dawb.workbench.ui.test/src/org/dawb/workbench/ui/editors/test/.

Source file: LargeFilesTest.java

  22 
vote

@BeforeClass public static void before() throws Exception {
  ModelUtils.createWorkflowProject("workflows",ResourcesPlugin.getWorkspace().getRoot(),true,null);
  DataProjectUtils.createDataProject("data",ResourcesPlugin.getWorkspace().getRoot(),true,null);
  ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,new NullProgressMonitor());
  final IProject data=ResourcesPlugin.getWorkspace().getRoot().getProject("data");
  final File dir=new File(System.getProperty("org.dawb.large.folder"));
  if (!dir.exists())   throw new Exception("Please set the large files folder system property and ensure it exists, 'org.dawb.large.folder'");
  final IFolder folder=data.getFolder(dir.getName());
  folder.createLink(dir.toURI(),IResource.DEPTH_ONE,null);
  folder.refreshLocal(IResource.DEPTH_ONE,null);
}
 

Example 7

From project dawn-workflow, under directory /org.dawb.passerelle.actors/src/org/dawb/passerelle/actors/edna/.

Source file: AbstractEdnaPlugin.java

  22 
vote

private IFolder getEdnaXmlFolder() throws Exception {
  final IContainer cont=getProject();
  final IFolder edna=cont.getFolder(new Path("edna-xml"));
  if (!edna.exists()) {
    try {
      edna.create(true,true,new NullProgressMonitor());
    }
 catch (    Exception ne) {
      logger.error("Did not create new folder " + edna.getName(),ne);
    }
  }
  return edna;
}
 

Example 8

From project dolphin, under directory /com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/.

Source file: TomcatProject.java

  22 
vote

public void addWEBINFLibJarFilesToProjectClasspath() throws CoreException {
  IFolder libFolder=this.getWebInfFolder().getFolder("lib");
  IResource[] libFiles=libFolder.members();
  IClasspathEntry[] entries=javaProject.getRawClasspath();
  List cp=new ArrayList(entries.length + 1);
  cp.addAll(Arrays.asList(entries));
  for (int i=0; i < libFiles.length; i++) {
    if ((libFiles[i].getType() == IResource.FILE) && (libFiles[i].getFileExtension().equalsIgnoreCase("jar"))) {
      cp.add(JavaCore.newLibraryEntry(libFiles[i].getFullPath(),null,null));
    }
  }
  javaProject.setRawClasspath((IClasspathEntry[])cp.toArray(new IClasspathEntry[cp.size()]),null);
}
 

Example 9

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/project/.

Source file: NewDroolsProjectWizard.java

  22 
vote

private void createOutputLocation(IJavaProject project,IProgressMonitor monitor) throws JavaModelException, CoreException {
  IFolder folder=project.getProject().getFolder("bin");
  createFolder(folder,monitor);
  IPath path=folder.getFullPath();
  project.setOutputLocation(path,null);
}
 

Example 10

From project Eclipse, under directory /com.mobilesorcery.sdk.core/src/com/mobilesorcery/sdk/internal/cdt/.

Source file: MoSyncIncludePathContainer.java

  22 
vote

private static List<IOutputEntry> createOutputEntries(IProject project){
  IFolder outputPath=project.getFolder(new Path(MoSyncBuilder.OUTPUT));
  IPath[] exclusionPattern=new IPath[]{new Path("rebuild.build.cpp")};
  List<IOutputEntry> result=new ArrayList<IOutputEntry>();
  addAsOutputEntryIfExists(result,outputPath,exclusionPattern);
  return result;
}
 

Example 11

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.frameworks.core/src/org/springsource/ide/eclipse/commons/frameworks/core/legacyconversion/.

Source file: LegacyProjectConverter.java

  22 
vote

private void convertRooProject(IProject project,SubMonitor sub) throws Exception {
  IFolder preferencesFolder=project.getFolder(".settings/");
  File settingsFile=preferencesFolder.getFile(ROO_OLD_PLUGIN_NAME + ".prefs").getLocation().toFile();
  File newSettingsFile=preferencesFolder.getFile(ROO_NEW_PLUGIN_NAME + ".prefs").getLocation().toFile();
  copyPreferencesFile(settingsFile,newSettingsFile,ROO_OLD_PLUGIN_NAME,ROO_NEW_PLUGIN_NAME);
  InstanceScope.INSTANCE.getNode(ROO_OLD_PLUGIN_NAME).sync();
  preferencesFolder.refreshLocal(IResource.DEPTH_ONE,sub);
}
 

Example 12

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.core.test/src/org/springsource/ide/eclipse/gradle/core/test/.

Source file: GradleTest.java

  22 
vote

public static void createFolder(IProject project,String srcPath) throws Exception {
  IFolder folder=project.getFolder(new Path(srcPath));
  if (folder.exists()) {
    folder.delete(true,new NullProgressMonitor());
  }
  create(folder);
}
 

Example 13

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task.ui/src/de/sebastianbenz/task/ui/editor/.

Source file: ExtLinkedFileHelper.java

  22 
vote

private void createLink(IProject project,IFile linkFile,java.net.URI uri) throws CoreException {
  IPath path=linkFile.getFullPath();
  IPath folders=path.removeLastSegments(1).removeFirstSegments(1);
  IPath checkPath=Path.ROOT;
  int segmentCount=folders.segmentCount();
  for (int i=0; i < segmentCount; i++) {
    checkPath=checkPath.addTrailingSeparator().append(folders.segment(i));
    IFolder folder=project.getFolder(checkPath);
    if (!folder.exists())     folder.create(true,true,null);
  }
  linkFile.createLink(uri,IResource.ALLOW_MISSING_LOCAL,null);
}
 

Example 14

From project eclipse.pde.build, under directory /org.eclipse.pde.build.tests/src/org/eclipse/pde/build/internal/tests/.

Source file: FetchTests.java

  22 
vote

public void testBug174194() throws Exception {
  IFolder buildFolder=newTest("174194");
  IFile script=buildFolder.getFile("testbuild.xml");
  try {
    runAntScript(script.getLocation().toOSString(),new String[]{"default"},buildFolder.getLocation().toOSString(),new Properties());
  }
 catch (  Exception e) {
    assertTrue(e.getMessage().endsWith("Could not retrieve feature.xml or build.properties for feature org.eclipse.rcp."));
  }
  assertResourceFile(buildFolder,"log.log");
  assertLogContainsLine(buildFolder.getFile("log.log"),"Could not retrieve feature.xml or build.properties for feature org.eclipse.rcp");
}
 

Example 15

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

Source file: FileLocationPage.java

  21 
vote

private String validate(){
  setMessage(null);
  String t=outputFolderWorkspaceLoc.getText();
  if (t == null) {
    return "Please specify folder";
  }
  Path path=new Path(t);
  if (!path.isValidPath(t) || path.segmentCount() < 2) {
    return "Please specify folder";
  }
  IFolder folder=ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
  if (!folder.exists()) {
    setMessage("Folder does not exist and will be created",DialogPage.WARNING);
  }
 else {
    IResource[] members=null;
    try {
      members=folder.members(true);
    }
 catch (    CoreException e) {
      return "Unable to retrieve this folder's state." + "Please check that the folder exists and is empty.";
    }
    if (members.length > 0) {
      setMessage("Folder is not empty. Folder members will be deleted.",DialogPage.WARNING);
    }
  }
  return null;
}
 

Example 16

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

Source file: SenecaManager.java

  21 
vote

/** 
 * Create a new specification in an sjs file.
 * @param filename the name of the file to create
 */
public boolean createSenecaJob(IContainer parent,String jobTitle) throws BioclipseException, CoreException {
  IFolder projectFolder=parent.getFolder(new Path(jobTitle));
  if (projectFolder.exists())   throw new BioclipseException("A directory " + parent.getFullPath() + " already exists");
  projectFolder.create(false,true,new NullProgressMonitor());
  SenecaJobSpecification specification=new SenecaJobSpecification();
  specification.setJobTitle(jobTitle);
  String extension="sjs";
  IFile file=projectFolder.getFile(new Path(jobTitle + "." + extension));
  boolean successful=net.bioclipse.seneca.Activator.getDefault().getJavaSenecaManager().saveSenecaJob(file,specification);
  if (successful) {
    net.bioclipse.ui.business.Activator.getDefault().getUIManager().open(file);
    return true;
  }
  return false;
}
 

Example 17

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.nmrshiftdb/src/net/bioclipse/nmrshiftdb/wizards/.

Source file: ElucidateWizard.java

  21 
vote

/** 
 * This method is called when 'Finish' button is pressed in the wizard. We will create an operation and run it using wizard as execution context.
 */
public boolean performFinish(){
  try {
    ISpectrum spectrum=new JumboSpectrum(cmlspectrum);
    net.bioclipse.nmrshiftdb.Activator.getDefault().getJavaNmrshiftdbManager().searchBySpectrum(spectrum,serverPage.selectedOption().equals("sub"),serverPage.getSelectedServer(),new BioclipseUIJob<List<ICDKMolecule>>(){
      @Override public void runInUI(){
        List<ICDKMolecule> result=getReturnValue();
        try {
          IFolder virtualfolder=NmrshiftdbUtils.createVirtualFolder();
          for (int i=0; i < result.size(); i++) {
            CDKMolecule cmlMol=(CDKMolecule)result.get(i);
            String similarity=(String)cmlMol.getAtomContainer().getProperty("similarity");
            ICDKManager manager=net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();
            String filename=(similarity.length() == 7 ? "0" + similarity : (similarity.length() == 6 ? "00" + similarity : similarity)) + " similarity" + i+ ".cml";
            manager.saveMolecule(cmlMol,virtualfolder.getFile(filename),(IChemFormat)CMLFormat.getInstance());
          }
          MessageBox mb=new MessageBox(new Shell(),SWT.ICON_INFORMATION | SWT.OK);
          mb.setMessage("Your result have been saved to " + virtualfolder.getFullPath().toOSString());
          mb.setText("NMRShiftDB search results saved");
          mb.open();
        }
 catch (        Exception ex) {
          LogUtils.handleException(ex,logger,Activator.ID);
        }
      }
    }
);
  }
 catch (  Exception ex) {
    LogUtils.handleException(ex,logger,Activator.ID);
  }
  return true;
}
 

Example 18

From project bundlemaker, under directory /main/org.bundlemaker.core.osgi/src/org/bundlemaker/core/osgi/exporter/pde/.

Source file: PdePluginProjectModuleExporter.java

  21 
vote

/** 
 * {@inheritDoc}
 */
@Override public void doExport(IProgressMonitor progressMonitor) throws CoreException {
  String projectName=Helper.getUniqueProjectName(getCurrentModule().getModuleIdentifier().getName());
  IPath location=null;
  if (isUseClassifcationForExportDestination()) {
    Path destinationDirectoryPath=new Path(getCurrentContext().getDestinationDirectory().getAbsolutePath());
    location=destinationDirectoryPath.append(getCurrentModule().getClassification()).append(projectName);
  }
  IProject project=Helper.deleteAndCreateProject(projectName,location);
  IProjectDescription description=project.getDescription();
  description.setNatureIds(new String[]{JavaCore.NATURE_ID,IBundleProjectDescription.PLUGIN_NATURE});
  project.setDescription(description,null);
  IJavaProject javaProject=JavaCore.create(project);
  javaProject.setRawClasspath(new IClasspathEntry[]{JavaRuntime.getDefaultJREContainerEntry()},null);
  javaProject.save(null,true);
  IBundleProjectService bundleProjectService=Activator.getBundleProjectService();
  IBundleProjectDescription bundleProjectDescription=bundleProjectService.getDescription(project);
  for (  String header : getManifestContents().getMainAttributes().keySet()) {
    bundleProjectDescription.setHeader(header,getManifestContents().getMainAttributes().get(header));
  }
  IBundleClasspathEntry bundleClasspathEntry=bundleProjectService.newBundleClasspathEntry(new Path(SRC_DIRECTORY_NAME),new Path(BIN_DIRECTORY_NAME),null);
  bundleProjectDescription.setBundleClassath(new IBundleClasspathEntry[]{bundleClasspathEntry});
  bundleProjectDescription.apply(null);
  IFolder srcFolder=project.getFolder(SRC_DIRECTORY_NAME);
  for (  IResource resourceStandin : getCurrentModule().getResources(ContentType.SOURCE)) {
    if (!resourceStandin.getPath().startsWith("META-INF")) {
      File targetFile=new File(srcFolder.getRawLocation().toFile(),resourceStandin.getPath());
      targetFile.getParentFile().mkdirs();
      try {
        FileUtils.copy(new ByteArrayInputStream(resourceStandin.getContent()),new FileOutputStream(targetFile),new byte[1024]);
      }
 catch (      Exception e) {
        throw new CoreException(new Status(IStatus.ERROR,Activator.BUNDLE_ID,"Unable to copy file " + resourceStandin.getRoot() + "to "+ targetFile+ ": "+ e,e));
      }
    }
  }
  srcFolder.refreshLocal(1,progressMonitor);
}
 

Example 19

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

Source file: ClojureBuilder.java

  21 
vote

private static Map<IFolder,IFolder> getSrcFolders(IProject project) throws CoreException {
  Map<IFolder,IFolder> srcFolders=new HashMap<IFolder,IFolder>();
  IJavaProject jProject=JavaCore.create(project);
  IClasspathEntry[] entries=jProject.getResolvedClasspath(true);
  IPath defaultOutputFolder=jProject.getOutputLocation();
  for (  IClasspathEntry entry : entries) {
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_SOURCE:
      IFolder folder=project.getWorkspace().getRoot().getFolder(entry.getPath());
    IFolder outputFolder=project.getWorkspace().getRoot().getFolder((entry.getOutputLocation() == null) ? defaultOutputFolder : entry.getOutputLocation());
  if (folder.exists())   srcFolders.put(folder,outputFolder);
break;
case IClasspathEntry.CPE_LIBRARY:
break;
case IClasspathEntry.CPE_PROJECT:
break;
case IClasspathEntry.CPE_CONTAINER:
case IClasspathEntry.CPE_VARIABLE:
default :
break;
}
}
return srcFolders;
}
 

Example 20

From project CIShell, under directory /templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/.

Source file: BasicTemplate.java

  21 
vote

public IFolder generateJavaSourceFolder(IFolder sourceFolder,IProgressMonitor monitor) throws CoreException {
  Object packageValue=getValue(KEY_PACKAGE_NAME);
  String packageName;
  if (packageValue != null) {
    packageName=packageValue.toString();
  }
 else {
    packageName=null;
  }
  if (packageName == null) {
    packageName=model.getPluginBase().getId();
  }
  IPath path=new Path(packageName.replace('.',File.separatorChar));
  if (sourceFolder != null) {
    path=sourceFolder.getProjectRelativePath().append(path);
  }
  for (int ii=1; ii <= path.segmentCount(); ii++) {
    IPath subpath=path.uptoSegment(ii);
    IFolder subfolder=project.getFolder(subpath);
    if (subfolder.exists() == false) {
      subfolder.create(true,true,monitor);
    }
  }
  return project.getFolder(path);
}
 

Example 21

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/project/.

Source file: FolderLinkWizard.java

  21 
vote

@Override public boolean performFinish(){
  try {
    final IContainer container=page.getProjectContainer();
    final File external=page.getExternalFolder();
    final IFolder folder=container.getFolder(new Path(external.getName()));
    getContainer().run(true,true,new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          monitor.beginTask("Creating link to " + folder.getName(),10);
          folder.createLink(external.toURI(),IResource.DEPTH_ONE,monitor);
          container.refreshLocal(IResource.DEPTH_ONE,monitor);
        }
 catch (        ResourceException e) {
          MessageDialog.openError(getShell(),"Cannot Import Folder",e.getMessage());
          logger.error("Cannot create link folder " + folder.getName(),e);
        }
catch (        CoreException e) {
          logger.error("Cannot create link folder " + folder.getName(),e);
        }
 finally {
          monitor.done();
        }
      }
    }
);
  }
 catch (  Exception ne) {
    logger.error("Cannot create link",ne);
    return false;
  }
  return true;
}
 

Example 22

From project dawn-tango, under directory /org.dawb.passerelle.actors.tango/src/org/dawb/passerelle/actors/hardware/.

Source file: TangoCommandTransformer.java

  21 
vote

protected IResource getResource(final boolean setParameterValue) throws Exception {
  String path=specFileParam.getExpression();
  IFile file=null;
  if (path == null || "".equals(path)) {
    final IProject project=getProject();
    final IContainer src=project.getFolder("src");
    file=IFileUtils.getUniqueIFile(src,"macro","mac");
    path=file.getFullPath().toOSString();
    path=StringUtil.replace(path,"/" + file.getProject().getName() + "/","/${project_name}/",true);
    if (setParameterValue)     specFileParam.setExpression(path);
  }
  if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) != null)   if (ResourcesPlugin.getWorkspace().getRoot().findMember(path).exists()) {
    file=(IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(path);
  }
  if (file == null) {
    path=ParameterUtils.substitute(path,this);
    final IProject project=getProject();
    final String srcP=IFileUtils.getPathWithoutProject(path.substring(0,path.lastIndexOf('/')));
    IContainer specDir=(IContainer)project.findMember(srcP);
    if (specDir == null) {
      try {
        IFolder srcf=project.getFolder(srcP);
        specDir=srcf;
      }
 catch (      Exception ne) {
        logger.error("Cannot create folder " + srcP,ne);
      }
    }
    final String fileName=path.substring(path.lastIndexOf('/'));
    file=(IFile)specDir.findMember(fileName);
    if (file == null && specDir instanceof IProject) {
      file=((IProject)specDir).getFile(fileName);
    }
    if (file == null && specDir instanceof IFolder) {
      file=((IFolder)specDir).getFile(fileName);
    }
  }
  return file;
}
 

Example 23

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.core/src/org/cloudfoundry/ide/eclipse/internal/server/core/standalone/.

Source file: StandaloneRuntimeResolver.java

  21 
vote

/** 
 * Gets full path for workspace paths. The path may be a path to a project relative folder, or to a project itself
 * @param relativePath
 * @return
 */
protected IPath getWorkspaceFullPath(IPath relativePath){
  if (relativePath == null) {
    return null;
  }
  IPath path=relativePath;
  if (path.segmentCount() == 1) {
    IProject project=ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
    if (project.isAccessible()) {
      path=project.getLocation();
    }
  }
 else {
    IFolder folder=ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
    if (folder.isAccessible()) {
      path=folder.getLocation();
    }
  }
  return path;
}
 

Example 24

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: ScalaModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new ScalaModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaModelWizard_label"));
  newFileCreationPage.setDescription(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaModelWizard_description"));
  newFileCreationPage.setFileName(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new ScalaModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(ScalaEditorPlugin.INSTANCE.getString("_UI_ScalaModelWizard_label"));
  initialObjectCreationPage.setDescription(ScalaEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}
 

Example 25

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

Source file: EclipseConWizard.java

  19 
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 26

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.database.editor/src/org/obeonetwork/dsl/database/presentation/.

Source file: DatabaseModelWizard.java

  19 
vote

/** 
 * The framework calls this to create the contents of the wizard. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void addPages(){
  newFileCreationPage=new DatabaseModelWizardNewFileCreationPage("Whatever",selection);
  newFileCreationPage.setTitle(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseModelWizard_label"));
  newFileCreationPage.setDescription(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseModelWizard_description"));
  newFileCreationPage.setFileName(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
  addPage(newFileCreationPage);
  if (selection != null && !selection.isEmpty()) {
    Object selectedElement=selection.iterator().next();
    if (selectedElement instanceof IResource) {
      IResource selectedResource=(IResource)selectedElement;
      if (selectedResource.getType() == IResource.FILE) {
        selectedResource=selectedResource.getParent();
      }
      if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
        String defaultModelBaseFilename=DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseEditorFilenameDefaultBase");
        String defaultModelFilenameExtension=FILE_EXTENSIONS.get(0);
        String modelFilename=defaultModelBaseFilename + "." + defaultModelFilenameExtension;
        for (int i=1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
          modelFilename=defaultModelBaseFilename + i + "."+ defaultModelFilenameExtension;
        }
        newFileCreationPage.setFileName(modelFilename);
      }
    }
  }
  initialObjectCreationPage=new DatabaseModelWizardInitialObjectCreationPage("Whatever2");
  initialObjectCreationPage.setTitle(DatabaseEditorPlugin.INSTANCE.getString("_UI_DatabaseModelWizard_label"));
  initialObjectCreationPage.setDescription(DatabaseEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
  addPage(initialObjectCreationPage);
}
 

Example 27

From project dawn-third, under directory /org.dawb.org.csstudio.swt.xygraph/src/org/csstudio/swt/xygraph/toolbar/.

Source file: TraceConfigPage.java

  19 
vote

/** 
 * Gets a unique file. The file must have a parent of IFolder.
 * @param file
 * @return new file, not created.
 */
public static IFile getUniqueFile(IFile file,final String conjunctive,final String extension){
  final String name=file.getName();
  final Matcher matcher=Pattern.compile("(.+)(\\d+)\\." + extension,Pattern.CASE_INSENSITIVE).matcher(name);
  int start=0;
  String frag=name;
  try {
    frag=name.substring(0,name.lastIndexOf("."));
  }
 catch (  Throwable ignored) {
  }
  if (matcher.matches()) {
    frag=matcher.group(1);
    start=Integer.parseInt(matcher.group(2));
  }
  if (conjunctive != null) {
    frag=frag + conjunctive;
  }
  final IContainer parent=file.getParent();
  final IFile newFile;
  if (parent instanceof IFolder) {
    newFile=((IFolder)parent).getFile(frag + "." + extension);
  }
 else   if (parent instanceof IProject) {
    newFile=((IProject)parent).getFile(frag + "." + extension);
  }
 else {
    newFile=null;
  }
  if (newFile != null && !newFile.exists())   return newFile;
  return getUniqueFile(parent,frag,++start,extension);
}
 

Example 28

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/indexing/.

Source file: WorkspaceIndexer.java

  19 
vote

/** 
 * Deletes and re-indexes files in a folder
 * @param folder
 * @param monitor 
 * @throws Exception 
 */
public void updateFolder(IFolder folder,IProgressMonitor monitor) throws Exception {
  if (!isIndexed())   return;
  IndexReader reader=IndexReader.open(getIndexDir(),false);
  deleteFolder(reader,folder);
  reader.close();
  if (!folder.isAccessible())   return;
  resourceCollector.clear();
  resourceCollector.setExcludedDirRegExes(excludedDirRegExes);
  folder.accept(resourceCollector);
  IndexWriter w=createIndexWriter(false);
  for (  IContainer container : resourceCollector.getContainers()) {
    if (isExcluded(container))     continue;
    indexContainer(w,container,monitor);
  }
  w.close();
}