Search in sources :

Example 91 with IFolder

use of org.eclipse.core.resources.IFolder in project AutoRefactor by JnRouvignac.

the class JavaCoreHelper method createJavaProject.

public static IJavaProject createJavaProject(String projectName, String binFolderName) throws Exception {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = root.getProject(projectName);
    if (!project.exists()) {
        project.create(null);
    } else {
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
    }
    if (!project.isOpen()) {
        project.open(null);
    }
    final IFolder binFolder = project.getFolder(binFolderName);
    createFolder(binFolder);
    addNatureToProject(project, JavaCore.NATURE_ID);
    final IJavaProject javaProject = JavaCore.create(project);
    javaProject.setOutputLocation(binFolder.getFullPath(), null);
    javaProject.setRawClasspath(new IClasspathEntry[0], null);
    return javaProject;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 92 with IFolder

use of org.eclipse.core.resources.IFolder in project AutoRefactor by JnRouvignac.

the class JavaCoreHelper method addSourceContainer.

private static IPackageFragmentRoot addSourceContainer(IJavaProject javaProject, String containerName) throws Exception {
    final IProject project = javaProject.getProject();
    final IFolder folder = project.getFolder(containerName);
    createFolder(folder);
    IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
    IClasspathEntry cpe = JavaCore.newSourceEntry(root.getPath(), EMPTY_PATHS, EMPTY_PATHS, null);
    addToClasspath(javaProject, Arrays.asList(cpe));
    return root;
}
Also used : IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 93 with IFolder

use of org.eclipse.core.resources.IFolder in project azure-tools-for-java by Microsoft.

the class CreateProjectUtil method createSampleFile.

public static void createSampleFile(@NotNull String id, @NotNull String projectName) throws CoreException {
    final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    final IFolder sourceRootFolder = project.getFolder("src");
    if (!sourceRootFolder.exists()) {
        sourceRootFolder.create(false, true, null);
    }
    final String rootPath = sourceRootFolder.getLocation().toFile().getAbsolutePath();
    switch(id) {
        case "com.microsoft.azure.hdinsight.local-scala.projwizard":
            createResourceStructForLocalRunScalaProject(sourceRootFolder, rootPath, project);
            AppInsightsClient.create(Messages.SparkProjectSystemScalaCreation, null);
            break;
        case "com.microsoft.azure.hdinsight.local-java.projwizard":
            AppInsightsClient.create(Messages.SparkProjectSystemJavaSampleCreation, null);
            copyFileTo(Java_Local_RunSample, rootPath);
            break;
        case "com.microsoft.azure.hdinsight.cluster-scala.projwizard":
            AppInsightsClient.create(Messages.SparkProjectSystemScalaSampleCreation, null);
            copyFileTo(Scala_Cluster_Run_Sample, rootPath);
            break;
        default:
            break;
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 94 with IFolder

use of org.eclipse.core.resources.IFolder in project gfm_viewer by satyagraha.

the class GenerateMarkdownPreview method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    LOGGER.fine("");
    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
    for (@SuppressWarnings("rawtypes") Iterator items = selection.iterator(); items.hasNext(); ) {
        Object item = items.next();
        if (item instanceof IFile) {
            scheduler.generateIFile((IFile) item);
        } else if (item instanceof IFolder) {
            scheduler.generateIFolder((IFolder) item);
        } else {
            LOGGER.fine("unexpected selection: " + item);
        }
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IFolder(org.eclipse.core.resources.IFolder)

Example 95 with IFolder

use of org.eclipse.core.resources.IFolder in project dbeaver by serge-rider.

the class ScriptsExportWizard method exportScripts.

public void exportScripts(DBRProgressMonitor monitor, final ScriptsExportData exportData) throws IOException, CoreException, InterruptedException {
    Collection<IResource> scripts = exportData.getScripts();
    int totalFiles = 0;
    for (IResource res : scripts) {
        if (res instanceof IFolder) {
            totalFiles += countFiles((IFolder) res);
        } else {
            totalFiles++;
        }
    }
    monitor.beginTask("Export scripts", totalFiles);
    for (IResource res : scripts) {
        if (res instanceof IFolder) {
            exportFolder(monitor, (IFolder) res, exportData);
        } else {
            exportScript(monitor, (IFile) res, exportData);
        }
    }
    monitor.done();
}
Also used : IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IFolder (org.eclipse.core.resources.IFolder)299 IFile (org.eclipse.core.resources.IFile)129 IPath (org.eclipse.core.runtime.IPath)90 IProject (org.eclipse.core.resources.IProject)77 CoreException (org.eclipse.core.runtime.CoreException)72 IResource (org.eclipse.core.resources.IResource)66 Path (org.eclipse.core.runtime.Path)47 IContainer (org.eclipse.core.resources.IContainer)45 File (java.io.File)43 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)31 IOException (java.io.IOException)28 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)26 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)23 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)19 InputStream (java.io.InputStream)18 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)17 IRunProcessService (org.talend.designer.runprocess.IRunProcessService)17 PersistenceException (org.talend.commons.exception.PersistenceException)16 ByteArrayInputStream (java.io.ByteArrayInputStream)15