private BuildActionGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider, RefreshAction refreshAction) { fSelectionProvider= specialSelectionProvider != null ? specialSelectionProvider : site.getSelectionProvider(); fBuildAction= new BuildAction(new ShellProviderAdapter(site.getShell()), IncrementalProjectBuilder.INCREMENTAL_BUILD); fBuildAction.setText(ActionMessages.BuildAction_label); fBuildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT); fRefreshAction= refreshAction; fRefreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); if (specialSelectionProvider != null) { fRefreshAction.setSpecialSelectionProvider(specialSelectionProvider); } fSelectionProvider.addSelectionChangedListener(fBuildAction); fSelectionProvider.addSelectionChangedListener(fRefreshAction); }
private static void startBuildJob(IProject proj) { BuildAction build = new BuildAction( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), IncrementalProjectBuilder.FULL_BUILD); build.selectionChanged(new StructuredSelection(proj)); build.runInBackground(null); }
/** * Causes all editors to save any modified resources in the provided collection * of projects depending on the user's preference. * @param projects The projects in which to save editors, or <code>null</code> * to save editors in all projects. */ public static void saveEditors(Indexable<IProject> projects) { if (!BuildAction.isSaveAllSet()) { return; } IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (int i = 0; i < windows.length; i++) { IWorkbenchPage[] pages = windows[i].getPages(); for (int j = 0; j < pages.length; j++) { IWorkbenchPage page = pages[j]; if (projects == null) { page.saveAllEditors(false); } else { IEditorPart[] editors = page.getDirtyEditors(); for (int k = 0; k < editors.length; k++) { IEditorPart editor = editors[k]; IFile inputFile = ResourceUtil.getFile(editor.getEditorInput()); if (inputFile != null) { if (projects.contains(inputFile.getProject())) { page.saveEditor(editor, false); } } } } } } }
public BuildOperationsActionGroup(IViewPart viewPart) { super(viewPart); buildAction = new BuildAction(() -> viewPart.getSite().getShell(), IncrementalProjectBuilder.INCREMENTAL_BUILD); buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT); }