private void doInitializeCache() throws CoreException { if (!isInitialized) { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { if (!isInitialized) { for (IProject project : workspace.getRoot().getProjects()) { if (project.isAccessible() && JavaProject.hasJavaNature(project)) { IJavaProject javaProject = JavaCore.create(project); updateCache(javaProject); } } isInitialized = true; } } }; // while the tree is locked, workspace.run may not be used but we are sure that we do already // hold the workspace lock - save to just run the action code if (workspace.isTreeLocked()) { runnable.run(null); } else { workspace.run(runnable, null, IWorkspace.AVOID_UPDATE, null); } } }
@Override protected void executeOperation() throws CoreException { m_runnable.run(m_progressMonitor); }
@Override public void performApply(IProgressMonitor monitor) throws CoreException { // Missing builder info if (fBuildInfo == null) { return; } if (monitor == null) { monitor = new NullProgressMonitor(); } IWorkspace workspace = MakeUIPlugin.getWorkspace(); // To avoid multi-build IWorkspaceRunnable operation = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { monitor.beginTask( MakeUIPlugin.getResourceString("SettingsBlock.monitor.applyingSettings"), 1); //$NON-NLS-1$ IMakeBuilderInfo info = null; if (getContainer().getProject() != null) { try { info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID); } catch (CoreException e) { // disabled builder... just log it MakeCorePlugin.log(e); return; } } else { info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false); } info.setStopOnError(isStopOnError()); info.setUseDefaultBuildCmd(useDefaultBuildCmd()); if (!useDefaultBuildCmd()) { String bldLine = getBuildLine(); int start = 0; int end = -1; if (!bldLine.startsWith("\"")) { // $NON-NLS-1$ end = bldLine.indexOf(' '); } else { start = 1; end = bldLine.indexOf('"', 1); } String path; if (end == -1) { path = bldLine; } else { path = bldLine.substring(start, end); } info.setBuildAttribute(IMakeBuilderInfo.BUILD_COMMAND, path); String args = ""; // $NON-NLS-1$ if (end != -1) { args = bldLine.substring(end + 1); } info.setBuildAttribute(IMakeBuilderInfo.BUILD_ARGUMENTS, args); } info.setAutoBuildEnable(autoButton.getSelection()); info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, targetAuto.getText().trim()); info.setIncrementalBuildEnable(incrButton.getSelection()); info.setBuildAttribute( IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, targetIncr.getText().trim()); info.setFullBuildEnable(incrButton.getSelection()); info.setCleanBuildEnable(cleanButton.getSelection()); info.setBuildAttribute( IMakeBuilderInfo.BUILD_TARGET_CLEAN, targetClean.getText().trim()); if (buildLocation != null) { info.setBuildAttribute( IMakeBuilderInfo.BUILD_LOCATION, buildLocation.getText().trim()); } } }; if (getContainer().getProject() != null) { workspace.run(operation, monitor); } else { operation.run(monitor); } }