private GradleProject getContext() { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win == null ? null : win.getActivePage(); if (page != null) { ISelection selection = page.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (!ss.isEmpty()) { Object obj = ss.getFirstElement(); if (obj instanceof IResource) { IResource rsrc = (IResource) obj; IProject prj = rsrc.getProject(); if (prj != null) { return GradleCore.create(prj); } } } } IEditorPart part = page.getActiveEditor(); if (part != null) { IEditorInput input = part.getEditorInput(); IResource rsrc = (IResource) input.getAdapter(IResource.class); if (rsrc != null) { IProject prj = rsrc.getProject(); if (prj != null) { return GradleCore.create(prj); } } } } return null; }
private void projectComboChanged() { String newProjectName = projectCombo.getText(); if ("".equals(newProjectName)) { setProject(null); } else { IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(newProjectName); setProject(GradleCore.create(newProject)); } }
private List<GradleProject> getGradleProjects() { IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); ArrayList<GradleProject> result = new ArrayList<GradleProject>(); for (IProject p : projects) { try { if (p.isAccessible() && p.hasNature(GradleNature.NATURE_ID)) { result.add(GradleCore.create(p)); } } catch (CoreException e) { GradleCore.log(e); } } return result; }
protected boolean shouldConfigureApt(EclipseProject gradleModel) { return AptUtils.isAptEnabled(GradleCore.create(gradleModel).getJavaProject()) || shouldEnableApt(gradleModel); }