Java Code Examples for org.eclipse.core.resources.IWorkspaceDescription#isAutoBuilding()

The following examples show how to use org.eclipse.core.resources.IWorkspaceDescription#isAutoBuilding() . 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: 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 3
Source File: Repository.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void enableBuild() {
    Job.getJobManager().wakeUp(ResourcesPlugin.FAMILY_AUTO_BUILD);
    final IWorkspaceDescription desc = workspace.getDescription();
    if (desc != null && !desc.isAutoBuilding()) {
        final boolean enableAutobuild = PlatformUI.isWorkbenchRunning();
        desc.setAutoBuilding(enableAutobuild);
        try {
            workspace.setDescription(desc);
        } catch (final CoreException e) {
            BonitaStudioLog.error(e, CommonRepositoryPlugin.PLUGIN_ID);
        }
        RepositoryManager.getInstance().getPreferenceStore().setValue(RepositoryPreferenceConstant.BUILD_ENABLE,
                enableAutobuild);
    }
}
 
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: IResourcesSetupUtil.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static boolean setAutobuild(boolean enable) {
	IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
	boolean oldValue = description.isAutoBuilding();
	if (oldValue != enable) {
		description.setAutoBuilding(enable);
		try {
			ResourcesPlugin.getWorkspace().setDescription(description);
		} catch (CoreException e) {
			Exceptions.sneakyThrow(e);
		}
	}
	return oldValue;
}
 
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: 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 8
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 9
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 10
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 11
Source File: ProjectTestUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Enables or disables automatic building of projects.
 */
public static void setAutoBuilding(boolean enable) throws CoreException {
  IWorkspaceDescription desc = ResourcesPlugin.getWorkspace().getDescription();
  if (desc.isAutoBuilding() != enable) {
    desc.setAutoBuilding(enable);
    ResourcesPlugin.getWorkspace().setDescription(desc);
  }
}
 
Example 12
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 13
Source File: Repository.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void disableBuild() {
    final IWorkspaceDescription desc = workspace.getDescription();
    if (desc != null && desc.isAutoBuilding()) {
        desc.setAutoBuilding(false);
        try {
            workspace.setDescription(desc);
        } catch (final CoreException e) {
            BonitaStudioLog.error(e, CommonRepositoryPlugin.PLUGIN_ID);
        }
        RepositoryManager.getInstance().getPreferenceStore().setValue(RepositoryPreferenceConstant.BUILD_ENABLE,
                false);
    }
}
 
Example 14
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();
}
 
Example 15
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isAutoBuilding() {
    IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
    return description.isAutoBuilding();
}