Java Code Examples for org.eclipse.core.resources.IWorkspace#getDescription()

The following examples show how to use org.eclipse.core.resources.IWorkspace#getDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutobuildUtils.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/** Sets workspace auto-build according to the provided flag. Thrown exceptions are handled by logging. */
static public void set(boolean enable) {
	if (isWorkbenchRunning()) {
		IWorkspace workspace = getWorkspace();
		IWorkspaceDescription workspaceDescription = workspace.getDescription();
		if (null != workspaceDescription) {
			if (workspaceDescription.isAutoBuilding() != enable) {
				workspaceDescription.setAutoBuilding(enable);
				try {
					LOG.info("Turning auto-build " + (enable ? "on" : "off") + "...");
					workspace.setDescription(workspaceDescription);
					LOG.info("Auto-build was successfully turned " + (enable ? "on" : "off") + ".");
				} catch (CoreException e) {
					throw new IllegalStateException("Error while trying to turn workspace autobuild "
							+ (enable ? "on" : "off") + ".", e);
				}
			}
		}
	} else {
		LOG.info("Workbench is not running, cannot change autobuild settings.");
	}
}
 
Example 2
Source File: StandardPreferenceManager.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private void updateParallelBuild(int maxConcurrentBuilds) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription description = workspace.getDescription();
	if (description.getMaxConcurrentBuilds() == maxConcurrentBuilds) {
		return;
	}

	description.setMaxConcurrentBuilds(maxConcurrentBuilds);
	try {
		workspace.setDescription(description);
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Problems setting maxConcurrentBuilds from workspace.", e);
	}

	String stringValue = maxConcurrentBuilds != 1 ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
	IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
	pref.put(MavenPreferenceConstants.P_BUILDER_USE_NULL_SCHEDULING_RULE, stringValue);
	pref = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
}
 
Example 3
Source File: XtextTestProjectManager.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean setAutobuild(final boolean autoBuildStatus) {
  synchronized (autoBuildMutex) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription description = workspace.getDescription();
    boolean oldAutoBuildStatus = description.isAutoBuilding();
    if (oldAutoBuildStatus != autoBuildStatus) {
      description.setAutoBuilding(autoBuildStatus);
      try {
        workspace.setDescription(description);
      } catch (CoreException e) {
        throw new WrappedException("Failed to set workspace description", e);
      }
    }
    return oldAutoBuildStatus;
  }
}
 
Example 4
Source File: BaseTest.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static Boolean setWorkspaceAutoBuild(boolean enabled) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription wsDescription = workspace.getDescription();
	boolean origEnabled = wsDescription.isAutoBuilding();
	if (enabled != origEnabled) {
		try {
			wsDescription.setAutoBuilding(enabled);
			workspace.setDescription(wsDescription);
			return origEnabled ? Boolean.TRUE : Boolean.FALSE;
		} catch (CoreException e) {
			TestUtil.print("Failed to set workspace auto build enabled to: " + enabled, e);
		}
	}
	return null;
}
 
Example 5
Source File: InternalBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void setAutoBuild(boolean b) {
	System.out.println("Setting auto-build to " + b);

	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	try {
		IWorkspaceDescription desc = workspace.getDescription();
		desc.setAutoBuilding(b);
		workspace.setDescription(desc);
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
 
Example 6
Source File: ProjectsManager.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static boolean setAutoBuilding(boolean enable) throws CoreException {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription description = workspace.getDescription();
	boolean changed = description.isAutoBuilding() != enable;
	if (changed) {
		description.setAutoBuilding(enable);
		workspace.setDescription(description);
	}
	return changed;
}
 
Example 7
Source File: JavaSyntaxServerTestPlugin.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void start(BundleContext context) throws Exception {
	JavaCore.initializeAfterLoad(new NullProgressMonitor());
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription description = workspace.getDescription();
	description.setAutoBuilding(false);
	workspace.setDescription(description);
}
 
Example 8
Source File: JavaLanguageServerTestPlugin.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void start(BundleContext context) throws Exception {
	TestVMType.setTestJREAsDefault("1.8");
	JavaCore.initializeAfterLoad(new NullProgressMonitor());
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription description = workspace.getDescription();
	description.setAutoBuilding(true);
	workspace.setDescription(description);
}
 
Example 9
Source File: BuilderUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean setAutoBuilding(boolean state) throws CoreException {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    boolean isAutoBuilding = desc.isAutoBuilding();
    if (isAutoBuilding != state) {
        desc.setAutoBuilding(state);
        workspace.setDescription(desc);
    }
    return isAutoBuilding;
}
 
Example 10
Source File: FindBugsAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void run(final IAction action) {
    if (selection == null || selection.isEmpty()) {
        return;
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription description = workspace.getDescription();
    if (!description.isAutoBuilding() && getClass().equals(FindBugsAction.class)) {
        boolean confirm = MessageDialog.openConfirm(null, "Project -> 'Build Automatically' disabled",
                "You are going to run SpotBugs analysis on a not compiled or partially compiled project.\n\n"
                        + "To get reliable analysis results, you should make sure that project is compiled first.\n\n"
                        + "Continue with SpotBugs analysis?");
        if (!confirm) {
            return;
        }
    }

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sSelection = (IStructuredSelection) selection;

        dialogAlreadyShown = false;

        Map<IProject, List<WorkItem>> projectMap = ResourceUtils.getResourcesPerProject(sSelection);

        for (Map.Entry<IProject, List<WorkItem>> e : projectMap.entrySet()) {
            work(targetPart, e.getKey(), e.getValue());
        }
        targetPart = null;
        selection = null;
    }
}
 
Example 11
Source File: JavaProjectHelper.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Sets auto-building state for the test workspace.
 *
 * @param state
 *            The new auto building state
 * @return The previous state
 * @throws CoreException
 *             Change failed
 */
public static boolean setAutoBuilding(boolean state) throws CoreException {
    // disable auto build
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    boolean result = desc.isAutoBuilding();
    desc.setAutoBuilding(state);
    workspace.setDescription(desc);
    return result;
}
 
Example 12
Source File: BuildAffectionTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: BuildAffectionTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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);
}
 
Example 14
Source File: CoreUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
* Sets whether building automatically is enabled in the workspace or not and returns the old
* value.
* 
* @param state <code>true</code> if automatically building is enabled, <code>false</code>
*            otherwise
* @return the old state
* @throws CoreException thrown if the operation failed
*/
  public static boolean setAutoBuilding(boolean state) throws CoreException {
      IWorkspace workspace= ResourcesPlugin.getWorkspace();
      IWorkspaceDescription desc= workspace.getDescription();
      boolean isAutoBuilding= desc.isAutoBuilding();
      if (isAutoBuilding != state) {
          desc.setAutoBuilding(state);
          workspace.setDescription(desc);
      }
      return isAutoBuilding;
  }
 
Example 15
Source File: CommonCoreTest.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected static void disableAutoBuild() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription desc= workspace.getDescription();
	desc.setAutoBuilding(false);
	try {
		workspace.setDescription(desc);
	} catch (CoreException e) {
		throw melnorme.utilbox.core.ExceptionAdapter.unchecked(e);
	}
}
 
Example 16
Source File: JDTLanguageServerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
private boolean isAutoBuilding() throws CoreException {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription description = workspace.getDescription();
	return description.isAutoBuilding();
}