/** * @param resource * @return true if the fViewer has updated its input, false otherwise */ protected boolean refreshComponents(IProject project) { IRteProject rteProject = CpProjectPlugIn.getRteProjectManager().getRteProject(project); if (rteProject != null) { ICpCodeTemplate codeTemplate = rteProject.getRteConfiguration().getCmsisCodeTemplate(); fViewer.setInput(codeTemplate); fViewer.getControl().setFocus(); return true; } return false; }
/** Open the browser to select project */ void handleProjectBrowse() { Set<IRteProject> rteProjects = new HashSet<IRteProject>(); for (IRteProject p : CpProjectPlugIn.getRteProjectManager().getRteProjects()) { if (p.getProject().isOpen()) { rteProjects.add(p); } } ProjectSelectionDialog dialog = new ProjectSelectionDialog(getShell(), rteProjects); if (dialog.open() == Window.OK) { Object[] result = dialog.getResult(); if (result != null && result.length == 1) { projectText.setText(((IRteProject) result[0]).getName()); } } }
private IRteProject getRteProject() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) { return null; } Object obj = ssel.getFirstElement(); IResource res = ProjectUtils.getResource(obj); if (res != null) { return CpProjectPlugIn.getRteProjectManager().getRteProject(res.getProject()); } } return null; }