Search in sources :

Example 46 with IWorkspace

use of org.eclipse.core.resources.IWorkspace in project xtext-xtend by eclipse.

the class BuildAffectionTest method tearDownProject.

@AfterClass
public static void tearDownProject() throws Exception {
    IResourcesSetupUtil.cleanWorkspace();
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IWorkspaceDescription description = workspace.getDescription();
    description.setAutoBuilding(BuildAffectionTest.wasAutoBuilding);
    workspace.setDescription(description);
}
Also used : IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IWorkspace(org.eclipse.core.resources.IWorkspace) AfterClass(org.junit.AfterClass)

Example 47 with IWorkspace

use of org.eclipse.core.resources.IWorkspace in project xtext-xtend by eclipse.

the class BuildAffectionTest method setUpProject.

@BeforeClass
public static void setUpProject() throws Exception {
    TargetPlatformUtil.setTargetPlatform(BuildAffectionTest.class);
    IResourcesSetupUtil.cleanWorkspace();
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IWorkspaceDescription description = workspace.getDescription();
    BuildAffectionTest.wasAutoBuilding = description.isAutoBuilding();
    description.setAutoBuilding(false);
    workspace.setDescription(description);
    WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME);
}
Also used : IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IWorkspace(org.eclipse.core.resources.IWorkspace) BeforeClass(org.junit.BeforeClass)

Example 48 with IWorkspace

use of org.eclipse.core.resources.IWorkspace in project xtext-xtend by eclipse.

the class PerformanceTestProjectSetup method createJavaProject.

public static IJavaProject createJavaProject(final String projectName, String[] projectNatures) {
    IProject project = null;
    IJavaProject javaProject = null;
    try {
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        project = workspace.getRoot().getProject(projectName);
        deleteProject(project);
        javaProject = JavaCore.create(project);
        IProjectDescription projectDescription = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
        project.create(projectDescription, null);
        List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
        projectDescription.setNatureIds(projectNatures);
        final ICommand java = projectDescription.newCommand();
        java.setBuilderName(JavaCore.BUILDER_ID);
        final ICommand manifest = projectDescription.newCommand();
        manifest.setBuilderName("org.eclipse.pde.ManifestBuilder");
        final ICommand schema = projectDescription.newCommand();
        schema.setBuilderName("org.eclipse.pde.SchemaBuilder");
        projectDescription.setBuildSpec(new ICommand[] { java, manifest, schema });
        project.open(null);
        project.setDescription(projectDescription, null);
        classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5")));
        classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins")));
        javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), null);
        makeJava5Compliant(javaProject);
        javaProject.setOutputLocation(new Path("/" + projectName + "/bin"), null);
        createManifest(projectName, project);
        // project.build(IncrementalProjectBuilder.FULL_BUILD, null);
        refreshExternalArchives(javaProject);
        refresh(javaProject);
    } catch (final Exception exception) {
        throw new RuntimeException(exception);
    }
    return javaProject;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IJavaProject(org.eclipse.jdt.core.IJavaProject) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ICommand(org.eclipse.core.resources.ICommand) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException)

Example 49 with IWorkspace

use of org.eclipse.core.resources.IWorkspace in project xtext-xtend by eclipse.

the class EclipseFileSystemTest method testGetURIForImportedProject.

@Test
public void testGetURIForImportedProject() {
    try {
        final IWorkspace ws = ResourcesPlugin.getWorkspace();
        final IWorkspaceRoot root = ws.getRoot();
        final IProjectDescription description = ws.newProjectDescription("bar");
        description.setLocation(root.getLocation().append("foo/bar"));
        final IProject project = root.getProject("bar");
        project.create(description, null);
        project.open(null);
        final Path file = new Path("/bar/Foo.text");
        Assert.assertFalse(this.fs.exists(file));
        Assert.assertNull(this.fs.toURI(file));
        try {
            this.fs.setContents(file, "Hello Foo");
            Assert.fail();
        } catch (final Throwable _t) {
            if (_t instanceof IllegalArgumentException) {
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
        Assert.assertFalse(this.fs.exists(file));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test) JavaIoFileSystemTest(org.eclipse.xtend.ide.tests.macros.JavaIoFileSystemTest)

Example 50 with IWorkspace

use of org.eclipse.core.resources.IWorkspace in project linuxtools by eclipse.

the class STDataViewersExportToCSVDialog method handleBrowseWorkspace.

private void handleBrowseWorkspace() {
    SaveAsDialog dialog = new SaveAsDialog(getShell());
    dialog.setTitle("Output file");
    if (dialog.open() == IDialogConstants.OK_ID) {
        IPath p = dialog.getResult();
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IFile file = workspace.getRoot().getFile(p);
        outputFile.setText(file.getLocation().toOSString());
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) IWorkspace(org.eclipse.core.resources.IWorkspace)

Aggregations

IWorkspace (org.eclipse.core.resources.IWorkspace)118 IProject (org.eclipse.core.resources.IProject)55 CoreException (org.eclipse.core.runtime.CoreException)54 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)37 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)36 IPath (org.eclipse.core.runtime.IPath)35 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)29 IStatus (org.eclipse.core.runtime.IStatus)27 IFile (org.eclipse.core.resources.IFile)24 PersistenceException (org.talend.commons.exception.PersistenceException)23 IProjectDescription (org.eclipse.core.resources.IProjectDescription)21 File (java.io.File)19 InvocationTargetException (java.lang.reflect.InvocationTargetException)19 Path (org.eclipse.core.runtime.Path)19 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)19 IResource (org.eclipse.core.resources.IResource)18 Status (org.eclipse.core.runtime.Status)14 IOException (java.io.IOException)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13 ArrayList (java.util.ArrayList)12