Search in sources :

Example 1 with IWorkspaceDescription

use of org.eclipse.core.resources.IWorkspaceDescription in project eclipse.platform.text by eclipse.

the class SearchPlugin method setAutoBuilding.

static boolean setAutoBuilding(boolean state) {
    IWorkspaceDescription workspaceDesc = getWorkspace().getDescription();
    boolean isAutobuilding = workspaceDesc.isAutoBuilding();
    if (isAutobuilding != state) {
        workspaceDesc.setAutoBuilding(state);
        try {
            getWorkspace().setDescription(workspaceDesc);
        } catch (CoreException ex) {
            ExceptionHandler.handle(ex, SearchMessages.Search_Error_setDescription_title, SearchMessages.Search_Error_setDescription_message);
        }
    }
    return isAutobuilding;
}
Also used : IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with IWorkspaceDescription

use of org.eclipse.core.resources.IWorkspaceDescription 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 3 with IWorkspaceDescription

use of org.eclipse.core.resources.IWorkspaceDescription 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 4 with IWorkspaceDescription

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

the class AbstractTest method createProject.

protected ICProject createProject(Bundle bundle, String projname) throws CoreException, URISyntaxException, IOException, InvocationTargetException, InterruptedException {
    // Turn off auto-building
    IWorkspace wsp = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = wsp.getDescription();
    desc.setAutoBuilding(false);
    wsp.setDescription(desc);
    ICProject proj = CProjectHelper.createCProject(projname, BIN_DIR);
    URL location = FileLocator.find(bundle, new Path("resources/" + projname), // $NON-NLS-1$
    null);
    File testDir = new File(FileLocator.toFileURL(location).toURI());
    IProject project = proj.getProject();
    // Add these natures before project is imported due to #273079
    ManagedCProjectNature.addManagedNature(project, null);
    ScannerConfigNature.addScannerConfigNature(project);
    ImportOperation op = new ImportOperation(project.getFullPath(), testDir, FileSystemStructureProvider.INSTANCE, pathString -> IOverwriteQuery.ALL);
    op.setCreateContainerStructure(false);
    op.run(null);
    IStatus status = op.getStatus();
    if (!status.isOK()) {
        throw new CoreException(status);
    }
    // Index the project
    IIndexManager indexManager = CCorePlugin.getIndexManager();
    indexManager.reindex(proj);
    indexManager.joinIndexer(IIndexManager.FOREVER, new NullProgressMonitor());
    // These natures must be enabled at this point to continue
    assertTrue(project.isNatureEnabled(ScannerConfigNature.NATURE_ID));
    assertTrue(project.isNatureEnabled(ManagedCProjectNature.MNG_NATURE_ID));
    return proj;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) ICProject(org.eclipse.cdt.core.model.ICProject) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) ImportOperation(org.eclipse.ui.wizards.datatransfer.ImportOperation) IIndexManager(org.eclipse.cdt.core.index.IIndexManager) LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject)

Example 5 with IWorkspaceDescription

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

the class PreferencesTest method setUpWorkbench.

@BeforeClass
public static void setUpWorkbench() throws Exception {
    // Set up is based from from GcovTest{c,CPP}.
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    try {
        // $NON-NLS-1$
        bot.viewByTitle("Welcome").close();
        // hide Subclipse Usage stats popup if present/installed
        // $NON-NLS-1$
        bot.shell("Subclipse Usage").activate();
        // $NON-NLS-1$
        bot.button("Cancel").click();
    } catch (WidgetNotFoundException e) {
    // ignore
    }
    // Set C/C++ perspective.
    // $NON-NLS-1$
    bot.perspectiveByLabel("C/C++").activate();
    bot.sleep(500);
    for (SWTBotShell sh : bot.shells()) {
        if (sh.getText().startsWith("C/C++")) {
            // $NON-NLS-1$
            sh.activate();
            bot.sleep(500);
            break;
        }
    }
    // Turn off automatic building by default to avoid timing issues
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    boolean isAutoBuilding = desc.isAutoBuilding();
    if (isAutoBuilding) {
        desc.setAutoBuilding(false);
        workspace.setDescription(desc);
    }
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IWorkspace(org.eclipse.core.resources.IWorkspace) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) BeforeClass(org.junit.BeforeClass)

Aggregations

IWorkspaceDescription (org.eclipse.core.resources.IWorkspaceDescription)8 IWorkspace (org.eclipse.core.resources.IWorkspace)6 BeforeClass (org.junit.BeforeClass)4 CoreException (org.eclipse.core.runtime.CoreException)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 File (java.io.File)2 URL (java.net.URL)2 IIndexManager (org.eclipse.cdt.core.index.IIndexManager)2 LocalFile (org.eclipse.core.internal.filesystem.local.LocalFile)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 Path (org.eclipse.core.runtime.Path)2 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)2 ImportOperation (org.eclipse.ui.wizards.datatransfer.ImportOperation)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URI (java.net.URI)1